On Fri, 2 Jan 2004, Amey Gokhale wrote:
below is a script ... which has many lines as comments at the start. still it works.
#test.sh #it doesn;t matter how
[snip]
this works but wonder in such case. ... which shell ll be invoked .... bash or csh?
/bin/sh or the current shell will be used. /bin/sh is generally a symlink to /bin/bash (it *must* be a link to a POSIX compliant shell. csh is not POSIX compliant)
i modified my script lil bit for testing purpose. now my script is
#!/bin/bash echo "IN BASH" #!/bin/csh echo "IN CSH"
it echoes both lines .... does tht mean i can write script (peculiar to different interpreters - bash/csh/ksh ... ) in a single script file like above? juss write the shell interpreter to be used at the start of each scripting section n then write code specific to tht shell in a single file ... is it feasible?
thks n regds, amey.
Philip S Tellis wrote:
On Fri, 2 Jan 2004, Amey Gokhale wrote:
below is a script ... which has many lines as comments at the start. still it works.
#test.sh #it doesn;t matter how
[snip]
this works but wonder in such case. ... which shell ll be invoked .... bash or csh?
/bin/sh or the current shell will be used. /bin/sh is generally a symlink to /bin/bash (it *must* be a link to a POSIX compliant shell. csh is not POSIX compliant)
On Fri, 2 Jan 2004, Amey Gokhale wrote:
#!/bin/bash echo "IN BASH" #!/bin/csh echo "IN CSH"
it echoes both lines .... does tht mean i can write script (peculiar to different interpreters - bash/csh/ksh ... ) in a single script file like
both are running under bash. The #!/bin/csh line is a regular shell comment, it does not affect the script in any way. The shell looks at the first two bytes of the file to determine what type of executable it is. If the first two bytes are #!, it is an interpreted program, and the rest of the line lists the path to the interpreter.
Please don't top-post.
On Fri, 2 Jan 2004, Amey Gokhale wrote:
~ i modified my script lil bit for testing purpose. ~ now my script is ~ ~ #!/bin/bash ~ echo "IN BASH" ~ #!/bin/csh ~ echo "IN CSH" ~
Dear you are confusing a lot of people. #! line has any significance *only* when its the first line.. otherwise its treated as a simple shell script and is executed by the shell u r using or by /bin/sh if its called by exec etc system calls.
Sameer mentions the first line thing very explicitly, dont know why are you getting confused.