Greetings, I'm new to both Linux and shell scripting. As part of the first project for a class I'm taking, my professor prepared a simple "Phonebook" bourne shell script. My customization only consisted in setting the global variable "Phonebook" relative to $HOME. It ran as expected on the University's Sun OS Server (v 2.6?), I could add, remove, list, look-up, and exit(the options provided for.) When I tried to run it on my home box (7.3 Pro), after chsh to /bin/sh from my original shell (I verified via "env" that my shell was changed), it acted "differently". Instead of prompting me that it was creating the Phonebook for me, it just showed the option display (which is the second thing that I expected to happen.) Instead of the cursor hanging out where it belonged, it printed the "\c" and moved down, so I removed that from the script, and added the "-n" flag to echo, which fixed that. The script allowed me to add a name/number, and I could open the "phonebook" created and see it, but when I entered the option for looking-up that entry, or the option for listing the contents, nothing happened. If I selected the option to remove an entry, it worked (I could tell by opening the "phonebook".) Is my "Bourne Shell" not /bin/sh ? Is it different somehow from the Solaris version? Is there an environment variable that I need to set? Sorry for the loooong post. steve
Why don't you just have a look? jw@suse3:~/dl/Pantomime > which sh /bin/sh jw@suse3:~/dl/Pantomime > ls -l /bin/sh lrwxrwxrwx 1 root root 4 Sep 22 18:21 /bin/sh -> bash jw@suse3:~/dl/Pantomime > which bash /bin/bash jw@suse3:~/dl/Pantomime > ls -l /bin/bash -rwxr-xr-x 1 root root 444188 May 15 2001 /bin/bash At 03:40 AM 2/8/2002 +0000, you wrote:
Greetings, I'm new to both Linux and shell scripting. As part of the first project for a class I'm taking, my professor prepared a simple "Phonebook" bourne shell script. My customization only consisted in setting the global variable "Phonebook" relative to $HOME. It ran as expected on the University's Sun OS Server (v 2.6?), I could add, remove, list, look-up, and exit(the options provided for.) When I tried to run it on my home box (7.3 Pro), after chsh to /bin/sh from my original shell (I verified via "env" that my shell was changed), it acted "differently". Instead of prompting me that it was creating the Phonebook for me, it just showed the option display (which is the second thing that I expected to happen.) Instead of the cursor hanging out where it belonged, it printed the "\c" and moved down, so I removed that from the script, and added the "-n" flag to echo, which fixed that. The script allowed me to add a name/number, and I could open the "phonebook" created and see it, but when I entered the option for looking-up that entry, or the option for listing the contents, nothing happened. If I selected the option to remove an entry, it worked (I could tell by opening the "phonebook".) Is my "Bourne Shell" not /bin/sh ? Is it different somehow from the Solaris version? Is there an environment variable that I need to set? Sorry for the loooong post.
steve
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq and the archives at http://lists.suse.com
---------------------------------------------------- Jonathan Wilson System Administrator Cedar Creek Software http://www.cedarcreeksoftware.com
>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<
On 2/7/02, 10:48:55 PM, JW
Why don't you just have a look?
jw@suse3:~/dl/Pantomime > which sh /bin/sh jw@suse3:~/dl/Pantomime > ls -l /bin/sh lrwxrwxrwx 1 root root 4 Sep 22 18:21 /bin/sh -> bash jw@suse3:~/dl/Pantomime > which bash /bin/bash jw@suse3:~/dl/Pantomime > ls -l /bin/bash -rwxr-xr-x 1 root root 444188 May 15 2001 /bin/bash
I'm not sure I understand what you are suggesting (I know, I'm thick) ... I know that my shell is /bin/sh (same as on the university's computer), and I know that the script is executing somewhat, so I don't think I need to be root to run it properly. What am I looking for? I'm trying to figure out why it's not executing EXACTLY like it did on the Sun OS server. If it could somehow make a difference, I did copy the folder holding the script onto a floppy from a Windows 2000 box at work, and then copied it into my home directory on my Linux box. steve
On Fri, 08 Feb 2002 04:21:24 GMT
Stephen Carbin
On 2/7/02, 10:48:55 PM, JW
wrote regarding Re: [SLE] Shell Scripting Problem:
. If it could somehow make a difference, I did copy the folder holding the script onto a floppy from a Windows 2000 box at work, and then copied it into my home directory on my Linux box.
Try doing a dos2unix conversion on the script. You may have translated the unix line endings to windows line endings; when it went thru 2000. To see it, type "joe myscript" ; if you see a bunch of ^M characters at the end of lines, that is the problem. $|=1;while(1){print pack("h*",'75861647f302d4560275f6272797f3');sleep(1); for(1..16){for(8,32,8,7){print chr($_);}select(undef,undef,undef,.05);}}
SC >>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<< SC >> jw@suse3:~/dl/Pantomime > ls -l /bin/sh SC >> lrwxrwxrwx 1 root root 4 Sep 22 18:21 /bin/sh -> bash SC > SC >I'm not sure I understand what you are suggesting (I know, I'm thick) ... SC >I know that my shell is /bin/sh (same as on the university's computer), SC >and I know that the script is executing somewhat, so I don't think I need SC >to be root to run it properly. No no, has nothing to do with root. What I'm suggesting is that it might now be the shell you think it is. On SuSE (Which I presume you are using, yes?), /bin/sh is a symlink to /bin/bash, so when you run /bin/sh you're actually running bash. Furthermore, it's bash2. Were you using bash2 on Solaris? I kinda doubt it. Read the manual page for bash, it talks about various switches you can use for debugging in order to discover exactly where your script breaks. SC > What am I looking for? I my example, you were "looking" to see what shelll you are really using. SC > I'm trying to SC >figure out why it's not executing EXACTLY like it did on the Sun OS SC >server. I assure you that it's because it's not the same shell. SC >If it could somehow make a difference, I did copy the folder SC >holding the script onto a floppy from a Windows 2000 box at work, and SC >then copied it into my home directory on my Linux box. It would make no differance at all unless you did it by opening the file in an editor and chooseing "Save As"... which might convert it to DOS line endings. Also, I just went back and read your originall post. It looks to me like you wrote it under bash (bourne shell) and now you're tring to run it under csh? You said chsh but there's no such shell, on SuSE csh would probably be tcsh. A bash script will _not_ run properly under csh. It would be good if you'd forsake the use of /bin/sh and call either bash or tcsh explicitly. ------------------------------------------------- Jonathan Wilson System Administrator Cedar Creek Software http://www.cedarcreeksoftware.com Central Texas IT http://www.centraltexasit.com
AHA! thanks JW, I think it's starting to make sense to me. First, when I said "chsh" , what i meant was the"change_shell" command... isn't it chsh? whatever the command actually was (I'm at work now on my Win 2000 box), it asked me what shell I wanted to change to: I selected /bin/sh. I did this because I thought it was the Bourne Shell...(I rebooted, issued the "env" command and it confirmed my shell as "/bin/sh")... isn't bash the Bourne-again shell, and more importantly, isn't it different from Bourne? This sounds EXACTLY like it is the problem. On the Sun Box at school (Sun Ultra 3000 running Solaris 2.6 (SVR4)), my shell is listed as "SHELL=/bin/sh" when I issue the "env" command.... so this means that /bin/sh IS different in SuSE 7.3 ? ... is there an equivalent shell to the Solaris one that I can use in SuSE 7.3? Please forgive my ignorance, I am a beginner. I am willing to read whatever is required to figure this out, I would have never thought of man bash, because I thought the Bourne shell was different from the bourne-again shell. I sincerely appreciate your response, I have a LOT to learn. steve At 12:08 PM 2/8/2002, JW wrote:
SC >>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<
SC >> jw@suse3:~/dl/Pantomime > ls -l /bin/sh SC >> lrwxrwxrwx 1 root root 4 Sep 22 18:21 /bin/sh -> bash
SC > SC >I'm not sure I understand what you are suggesting (I know, I'm thick) ... SC >I know that my shell is /bin/sh (same as on the university's computer), SC >and I know that the script is executing somewhat, so I don't think I need SC >to be root to run it properly.
No no, has nothing to do with root. What I'm suggesting is that it might now be the shell you think it is. On SuSE (Which I presume you are using, yes?), /bin/sh is a symlink to /bin/bash, so when you run /bin/sh you're actually running bash. Furthermore, it's bash2.
Were you using bash2 on Solaris? I kinda doubt it. Read the manual page for bash, it talks about various switches you can use for debugging in order to discover exactly where your script breaks.
SC > What am I looking for?
I my example, you were "looking" to see what shelll you are really using.
SC > I'm trying to SC >figure out why it's not executing EXACTLY like it did on the Sun OS SC >server.
I assure you that it's because it's not the same shell.
SC >If it could somehow make a difference, I did copy the folder SC >holding the script onto a floppy from a Windows 2000 box at work, and SC >then copied it into my home directory on my Linux box.
It would make no differance at all unless you did it by opening the file in an editor and chooseing "Save As"... which might convert it to DOS line endings.
Also, I just went back and read your originall post. It looks to me like you wrote it under bash (bourne shell) and now you're tring to run it under csh? You said chsh but there's no such shell, on SuSE csh would probably be tcsh. A bash script will _not_ run properly under csh.
It would be good if you'd forsake the use of /bin/sh and call either bash or tcsh explicitly.
------------------------------------------------- Jonathan Wilson System Administrator
Cedar Creek Software http://www.cedarcreeksoftware.com Central Texas IT http://www.centraltexasit.com
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq and the archives at http://lists.suse.com
On Fri, 2002-02-08 at 13:42, Stephen H Carbin wrote:
AHA! thanks JW, I think it's starting to make sense to me. First, when I said "chsh" , what i meant was the"change_shell" command... isn't it chsh? whatever the command actually was (I'm at work now on my Win 2000 box), it asked me what shell I wanted to change to: I selected /bin/sh. I did this because I thought it was the Bourne Shell...(I rebooted, issued the "env" command and it confirmed my shell as "/bin/sh")... isn't bash the Bourne-again shell, and more importantly, isn't it different from Bourne? This sounds EXACTLY like it is the problem. On the Sun Box at school (Sun Ultra 3000 running Solaris 2.6 (SVR4)), my shell is listed as "SHELL=/bin/sh" when I issue the "env" command.... so this means that /bin/sh IS different in SuSE 7.3 ? ... is there an equivalent shell to the Solaris one that I can use in SuSE 7.3? Please forgive my ignorance, I am a beginner. I am willing to read whatever is required to figure this out, I would have never thought of man bash, because I thought the Bourne shell was different from the bourne-again shell. I sincerely appreciate your response, I have a LOT to learn.
$SHELL contains a file name: /bin/sh. /bin/sh is a symbolic link to another file, which is the real shell program. What you need to determine is what files do the sym links /bin/sh point to. On SuSE, it should be /bin/bash. Solaris might be pointing to something different. The 'ls' command can dereference the link... # ls -l /bin/sh lrwxrwxrwx 1 root root 4 Jul 4 2001 /bin/sh -> bash This is from SuSE 7.2. It shows that /bin/sh is really pointing to the file /bin/bash, making it the Bourne again shell. -- Robert Wohlfarth rjwohlfar@galaxyinternet.net "Is not life more important than food, and the body more important than clothes?" -- Matthew 6:25b
On Fri, Feb 08, 2002 at 01:42:54PM -0500, Stephen H Carbin wrote:
AHA! thanks JW, I think it's starting to make sense to me. First, when I said "chsh" , what i meant was the"change_shell" command... isn't it chsh?
Sorry this is so late. chsh will change the user's shell. It does not affect which shell scripts run under. UNIX shell scripts tell the system which shell it should use to execute them with a special first line. For example: #!/bin/sh would execute the standard bourne shell on UNIX, but typically it calls Bash on Linux. In your case, the latter is happening, because /bin/sh is a symlink to /bin/bash. HTH, -v -- Victor R. Cardona Powered by SuSE Linux 7.1 (i386) Professional GPG key ID E81B3A1C Key fingerprint = 0147 A234 99C3 F4C5 BC64 F501 654F DB49 E81B 3A1C
participants (6)
-
JW
-
Robert Wohlfarth
-
Stephen Carbin
-
Stephen H Carbin
-
Victor R. Cardona
-
zentara