Operating System - HP-UX
1832840 Members
2888 Online
110047 Solutions
New Discussion

Re: Unable to execute Shell Script

 
uform
Frequent Advisor

Unable to execute Shell Script

Hi,

I'm in PA, connecting to an unix server in
NY with my id and able to execute following
script which has ,

#!/bin/ksh
echo "Script works"

Another team mate in MA, connecting to same unix server in NY with MY ID and NOT able to execute the same script.

getting " ksh: testingprg.sh: not found "

since he is using my id to login for same server, i dont think its a profile issue.

Can someone tell me what else to check.

PS: he is connecting to other unix servers (with his own ids) and same script works there.


Thanks
14 REPLIES 14
Pete Randall
Outstanding Contributor

Re: Unable to execute Shell Script

It sounds like a path problem. Have him try using the full path name.


Pete

Pete
spex
Honored Contributor

Re: Unable to execute Shell Script

Hello,

Perhaps your terminal emulator automatically appends the directory containing testingprg.sh to $PATH, while your colleague's emulator does not. If this is the case, note that the CWD (./) should NEVER be part of your path.

Also, /etc/profile or ~user/.profile could be setting paths differently based on originating host.

PCS
James R. Ferguson
Acclaimed Contributor

Re: Unable to execute Shell Script

Hi:

I suggest that you have your colleague tell you EXACTLY what he enters to run your script.

Perhaps:

You do:

$ ./testingprg.sh

...but he/she does:

$ testingprg.sh

Regards!

...JRF...
uform
Frequent Advisor

Re: Unable to execute Shell Script

script is avbl in

he is trying to execute the script from the
current directory. but where to set the path?
uform
Frequent Advisor

Re: Unable to execute Shell Script

my home dir = /export/home/usr9807

he created sub dir

/export/home/usr9807/fortest and created a
script(testingprg.sh) with above said contents.

Now he executes from that sub dir as
/export/home/usr9807/fortest>testingprg.sh
and getting " ksh: testingprg.sh: not found "

when he tries to
/export/home/usr9807/fortest>/export/home/usr9807/fortest/testingprg.sh

IT WORKS ...

why should he provide full path ? how to set the path and where ?

Please help thanks.
spex
Honored Contributor

Re: Unable to execute Shell Script

PATH=${PATH}:/path/to/script

This is typically done in /etc/profile and/or ~user/.profile.

PCS
spex
Honored Contributor

Re: Unable to execute Shell Script

/export/home/usr9807/fortest> ./testingprg.sh
will work for him.
uform
Frequent Advisor

Re: Unable to execute Shell Script

So shud i set PATH=${PATH}:/export/home/usr9807/fortest ??
inorder for him to execute as export/home/usr9807/fortest>testingprg.sh
instead of giving of full path ?

if thats the case why its working for me ?

for me this works
export/home/usr9807/fortest>testingprg.sh
TwoProc
Honored Contributor

Re: Unable to execute Shell Script

I'm thinking that "." is not in his path. Of course, if either him or yourself is logging in as root - you don't want to have "." in your path (and I have a suspicion that this is the case - that someone is logging in as root). If the username is not root - then it should be OK to add "." to their path - check their .profile for the PATH variable setting, and if necessary add "." to it.

If you ARE logged in as root and you need to execute something the current directory - then just prepend the "." to it.

So, instead of running
# myscript

you'd run
# ./myscript
We are the people our parents warned us about --Jimmy Buffett
uform
Frequent Advisor

Re: Unable to execute Shell Script

i havent changed anything in my profile yet.

But this is what i have currently.

# UNIX PATH specific
PATH=/usr/bin:/usr/local/bin:/usr/sbin:/usr/dt/bin:$OPENWIN/bin:$HOME/bin/:$PATH:.


i see ( . ) already at the end ..then it shud have worked right ?
hpuxrox
Respected Contributor

Re: Unable to execute Shell Script

First off, having the ( . ) in your PATH is a rather large security issue.

But anyways, Is he connected to the right machine? KISS
hpuxrox
Respected Contributor

Re: Unable to execute Shell Script

First off, having the ( . ) in your PATH is a rather large security issue.

But anyways, Is he connected to the right machine? KISS

Is he in the directory where the script resides? Have him use the complete path.
uform
Frequent Advisor

Re: Unable to execute Shell Script

yes , he is in current dir where script resides.
TwoProc
Honored Contributor

Re: Unable to execute Shell Script

DOH!!!

Man, my bad - I forgot that we had removed them all (".") when we did our server hardening. I can't believe I forgot that one - I'm just so used to typing "./" before things I wanted to run locally anyways for so many years as an admin - I never missed it when we removed it, as I had learned years and years ago not to depend on it.

Sorry for the bad advice, please ignore.
We are the people our parents warned us about --Jimmy Buffett