Discussion:
u5 scripting
(too old to reply)
t***@engmail.uwaterloo.ca
2004-06-25 01:07:00 UTC
Permalink
For the shell scripting questions in u5, which scripting language are we
supposed to use? Or can we use any scripting language of our choice?

Also, for problem 1, is backup.sh supposed to backup the directory tree rooted
at ~/cs241 as ~/.cs241.backup, or as ~/.cs241.backup/cs241?

----------------------------------------
This mail sent through www.mywaterloo.ca
Dan Heidinga
2004-06-25 02:20:48 UTC
Permalink
Hi,

To be on the safe side, here's how I can help:
type 'man csh'
type '/first character'

Regards,
Dan
t***@engmail.uwaterloo.ca
2004-06-25 03:32:15 UTC
Permalink
That text in the man page seems very strange to me. It looks to me as if it's
saying that the C-shell launches all shell scripts as either C-shell scripts
or Bourne shell scripts depending on if the first character is #, but that's
not true. For example, the C-shell correctly runs Perl scripts when the file
starts with #!/bin/perl, and that's not limited to just UW's system either. Am
I misinterpreting this text?

Quoting Dan Heidinga:

Hi,

To be on the safe side, here's how I can help:
type 'man csh'
type '/first character'

Regards,
Dan

----------------------------------------
This mail sent through www.mywaterloo.ca
Dan Heidinga
2004-06-25 05:19:10 UTC
Permalink
Hi,

Actually, if you read carefully, it states:

If the file is a text file
and the first line begins with #!, the next word is taken to
be the pathname of a shell (or command) to interpret that
script. Subsequent words on the first line are taken as
options for that shell. The kernel invokes (overlays) the
indicated shell, using the name of the script as an argu-
ment.

If neither of the above conditions holds, the kernel cannot
overlay the file and the execve() call fails (see exec(2));
the C shell then attempts to execute the file by spawning a
new shell, as follows:

o If the first character of the file is a #, a C shell
is invoked.

o Otherwise, a Bourne shell is invoked.

Hope that helps,
Dan
t***@engmail.uwaterloo.ca
2004-06-25 16:04:17 UTC
Permalink
Ahhh, I see. I just needed to go up one more paragraph. :) Anyways, the deal
with the #! is actually how I thought things worked. What I'm hoping to find
out from someone is what shell interpreters we are allowed to use. Personally,
I'd like to do all this in Perl. :)

Quoting Dan Heidinga:

Hi,

Actually, if you read carefully, it states:

If the file is a text file
and the first line begins with #!, the next word is taken to
be the pathname of a shell (or command) to interpret that
script. Subsequent words on the first line are taken as
options for that shell. The kernel invokes (overlays) the
indicated shell, using the name of the script as an argu-
ment.

If neither of the above conditions holds, the kernel cannot
overlay the file and the execve() call fails (see exec(2));
the C shell then attempts to execute the file by spawning a
new shell, as follows:

o If the first character of the file is a #, a C shell
is invoked.

o Otherwise, a Bourne shell is invoked.

Hope that helps,
Dan

----------------------------------------
This mail sent through www.mywaterloo.ca
Troy Mark Gonsalves
2004-06-28 16:31:49 UTC
Permalink
I guess Perl is ok...it is nice to learn new things though.

Troy
Post by t***@engmail.uwaterloo.ca
Ahhh, I see. I just needed to go up one more paragraph. :) Anyways, the deal
with the #! is actually how I thought things worked. What I'm hoping to find
out from someone is what shell interpreters we are allowed to use. Personally,
I'd like to do all this in Perl. :)
Hi,
If the file is a text file
and the first line begins with #!, the next word is taken to
be the pathname of a shell (or command) to interpret that
script. Subsequent words on the first line are taken as
options for that shell. The kernel invokes (overlays) the
indicated shell, using the name of the script as an argu-
ment.
If neither of the above conditions holds, the kernel cannot
overlay the file and the execve() call fails (see exec(2));
the C shell then attempts to execute the file by spawning a
o If the first character of the file is a #, a C shell
is invoked.
o Otherwise, a Bourne shell is invoked.
Hope that helps,
Dan
----------------------------------------
This mail sent through www.mywaterloo.ca
Loading...