reading stdin for tcsh script

Jonathan I. Kamens jik at athena.mit.edu
Fri Jan 18 01:13:48 AEST 1991


  Your shell script is not working because it is being evaluated by the bourne
shell, not by the C shell.  If you want your shell script to be evaluated by
the C shell, then put "#!/bin/csh -f" as the first line of the script (and
hope that either your kernel or your shells understand the "#!" notation; I
believe ultrix does).

Here's the script without a shell specification at the top:

    % cat test
    echo Enter NAME :
    set title = $<
    echo  Name : $title

Here's what happens when you run it:

    % ./test
    Enter NAME :
    ./test: syntax error at line 3: `newline' unexpected

Now we put a shell specification at the top:

    % ed test
    53
    1i
    #!/bin/csh -f
    .
    w
    67
    q

And run it again:

    % ./test
    Enter NAME :
    John Doe
    Name : John Doe
    %

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.shell mailing list