Wrong Shell Invoking My Script On Linux


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wrong Shell Invoking My Script On Linux
# 1  
Old 09-10-2003
Wrong Shell Invoking My Script On Linux

I have a shell script that does NOT have the '#!' line at the top. It is written for ksh. The shell in my passwd entry is '/usr/bin/ksh' and my SHELL env variable is '/usr/bin/ksh'. Now, here's the issue. I invoke the script on Solaris with './myprog'. This works fine. I also run the same script on Mandrake 9.0 Linux and Red Hat 7.3 Linux. It runs fine on both of these. Again, my SHELL env variable and passwd entry both have '/usr/bin/ksh'. When I invoke the program on Red Hat 7.2 with './myprog', it is using the '/bin/sh' shell. Why would this be ? If my SHELL var and passwd entry both point to 'ksh', I don't understand how it would be using '/bin/sh'. Also, I can't just add the '#!' line to the top because this script invokes other scripts as well and it just pushes the problem to a different point. Any ideas ????
# 2  
Old 09-10-2003
Re: Wrong Shell Invoking My Script On Linux

Quote:
Originally posted by kowrip
I have a shell script that does NOT have the '#!' line at the top.
Then it is broken.
Quote:
Originally posted by kowrip

Also, I can't just add the '#!' line to the top because this script invokes other scripts as well and it just pushes the problem to a different point. Any ideas ????
You have a finite number of scripts. And the #! line to each one.

As for what is happening, see this thread.
# 3  
Old 09-10-2003
Re: Re: Wrong Shell Invoking My Script On Linux

Quote:
Originally posted by Perderabo
Then it is broken.

You have a finite number of scripts. And the #! line to each one.

As for what is happening, see this thread.
Thanks. This behavior was quite surprising to me and my co-workers. We always thought that the system will use whatever your current $SHELL is to run scripts without the "#!". This script is a setup script for a bigger program and it was always without the "#!". I guess I'll add it to the top of the file now that I know.
# 4  
Old 09-10-2003
The second shell for unix was csh. Shortly after csh arrived, the SHELL environment variable was introduced. It was set to the value of the shell field in /etc/passwd. From it's inception, it was intended to be the user's favorite interactive shell. Programs like vi refer to it when when they are asked to spawn an interactive shell. If it also was for scripts, that would mean that we must use the same shell for interactive use and for scripts. csh was better than sh as an interactive shell but sh was better than csh for scripts.

The only exception to this that I know of is with the program "make". It reads the environment and treats each environment variable as a make macro. That includes the SHELL macro, the environment SHELL variable overrides make's internal deafault for SHELL. So all non-trivial makefiles now explicitly set the SHELL macro. make's habit of assuming that the entire environment is intended for it is not great behavior.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Invoking Application in Shell Script

Hi All, I have a scenario : 1. A list of servers naming server21, server 22, server 23 etc. This list of servers is separate for my environments. Env1 has 3 server Env2 has 5 serves Env3 has 10 servers 2. Each server accesses application through which I want to invoke some method. So... (7 Replies)
Discussion started by: ankur328
7 Replies

2. Shell Programming and Scripting

Problem invoking shell script

whats wrong here?! ________________ #!/bin/sh # FILE: clean_dirs # GOAL : To clean up directories used in Oracle processing # LANGUAGE : shell script (sh) # PARAMETERS : Input_File # 11/07/02 acri - modified to cd into the directory so it will... (7 Replies)
Discussion started by: gillraj
7 Replies

3. Shell Programming and Scripting

Invoking one shell script from another unix box

Hello All, I have a shell script A which is in one unix box. Also i have a script B in another unix box. Now i'm struggling to find a way to invoke A shell script from B shell script. Is it possible to do this in any way..Request you anybody please help me in this point. Thanks in advance. (6 Replies)
Discussion started by: RSC1985
6 Replies

4. Shell Programming and Scripting

Shell script..invoking command and exiting at fixed intervals

Hi, I need to write a shell script. Based on command line param to script say demode=yes Need to run an ant command for an hour(configurable) Then exit Again run the ant command all this needs to be in a loop. Thanks in advance Raj (1 Reply)
Discussion started by: rajuak12
1 Replies

5. UNIX for Advanced & Expert Users

Invoking shell script with perl command.

Hi All, I am using the following command to invoke the shell script from a perl command. perl -i.bak -pe'BEGIN { $cmd = "/opt/coreservices/tomcat-5.5.9/bin/digest.sh -a sha"; } s/(password=")(*)/ $1.`$cmd $2|cut -d: -f2|tr -d "\n"` /e ' $CATALINA_HOME/conf/tomcat-users.xml I need... (1 Reply)
Discussion started by: nua7
1 Replies

6. Shell Programming and Scripting

invoking a shell script inside cgi shell script

Hi, I have an HTML form through which I get some text as input. i need to run a shell script say script.sh inside a perl-cgi script named main_cgi.sh on the form input. I want to write the contents of the form in a file and then perform some command line operations like grep, cat on the text... (2 Replies)
Discussion started by: smriti_shridhar
2 Replies

7. Shell Programming and Scripting

returning to the parent shell after invoking a script within a script

Hi everybody, I have a script in which I'm invoking another script which runs in a subshell. after the script is executed I want to return to the parent shell as some variables are set. However i'm unable to return to my original shell as the script which i'm calling inside is invoked in... (5 Replies)
Discussion started by: gurukottur
5 Replies

8. Shell Programming and Scripting

Invoking Shell Script via php

list me commands to invoke a shell script from php once the submit button is clicked in the php page. Requirement is Once a submit button is clicked it should run a script that displays the outcome of the script in a html/php. Please help. Thanks in Advance, BubeshJ (2 Replies)
Discussion started by: bubeshj
2 Replies

9. Shell Programming and Scripting

Invoking shell script from html/jsp page

I want to invoke shell script named bubesh.sh when submit button clicked on html/jsp page.I am using an apache server and the html & shell script are in the same working directory.Please help. (2 Replies)
Discussion started by: bubeshj
2 Replies

10. Shell Programming and Scripting

invoking one shell script from other

hi, i am one day old in shell scritpting. how to invoke one shell script from the other? For eg.i have two shell scripts A.sh and B.sh. Inside A.sh i need to invoke B.sh and the return code of A.sh should be the value returned by B.sh. it would be better if you provide any sample shell... (3 Replies)
Discussion started by: ajay xavier
3 Replies
Login or Register to Ask a Question