Not Found message in script execution


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Not Found message in script execution
# 1  
Old 07-28-2010
Not Found message in script execution

Hi gurus,

I'm having a strange problem and I hope you can help me solving it.

I'm working in Unix Solaris, version 5.10, ksh.
I have a script with environment variables which I have to execute prior to other scripts. The script belongs to userA and when I log in, and cd to its directory. It doesn't work and the following message appears:
Code:
$ . load_env.sh
ksh: load_env.sh:  not found

The strange thing is that if I log in with a different user, userB, and then I do:
Code:
$ su - userA

Then cd to my script's directory and execute it, it works.

The command env returns similar results in both cases.

Thanks in advance for your help.

Regards

ermur
# 2  
Old 07-29-2010
It sounds like your PATH environmental variable may be the culprit.

What happens if you do?
Code:
$ . ./load_env.sh

# 3  
Old 07-29-2010
Hi fpmurphy,

In both cases the PATH variable is the same:

Code:
$ echo $PATH
/usr/bin::/opt/EMCpower/bin:/etc/emc/bin:/etc

if I use . ./ it works. However, I would like to have it working the other way (<dot><space>), since, this is not the only machine (the other 4 machines are working) with this configuration and the operations personnel have already been trained.

Thanks a lot for your help
# 4  
Old 07-30-2010
Quote:
/usr/bin::/opt/EMCpower/bin:/etc/emc/bin:/etc
The highlighted blank entry in $PATH is the equivalent of having a dot "." in $PATH (which is a known security issue). When your current working directory is the same as the script it will execute if the script is executable and the user has permission to execute the script.

Code:
Example.  See the effects of an extra colon in $PATH.

myscript.sh
echo "working"

PATH=/usr/bin
myscript.sh
sh: myscript.sh:  not found.

PATH=/usr/bin:
myscript.sh
working

PATH=:/usr/bin
myscript.sh
working


It is more secure to create a central scripts directory with the scripts owned by root and each script with permissions 755. Then append the scripts directory to $PATH in each user's .profile. Where there is a mixture of user groups on a machine it can be necessary to set the permissions to 750 and use secondary groups to control who can execute a script.

A central script can then be executed with the command you describe. We use this technique extensively for ease of maintenance. Also if a user owns a script they can change or delete it !
This User Gave Thanks to methyl For This Post:
# 5  
Old 07-30-2010
Thanks a lot for your valuable help.

ermur
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ssh from a ksh returning not found message

Script name is test.ksh I know that that the ssh command is working properly, this can be verified by the value returned in respond variable. It is unique to the remote server _____________________________________________________ respond=$(ssh $remoteHost find... (3 Replies)
Discussion started by: Adagio
3 Replies

2. UNIX for Dummies Questions & Answers

Find Null values in Columns and fail execution by displaying error message

Hi All, I am new to shell scripting. I have a requirement as part of my job to find out null/empty values in column 2 and column 3 from a CSV file and exit the further execution of script by displaying a simple error message. I have developed a script to do this by reading various articles... (7 Replies)
Discussion started by: tpk
7 Replies

3. Shell Programming and Scripting

Search for a tag and display a message if not found.

Hi All, I am working with a XML file. Below is part for the file. <Emp:Profile> <Emp:Description>Admin</Emp:Description> <Emp:Id>12347</Emp:Id> </Emp:Profile> <Emp:Profile> ... (7 Replies)
Discussion started by: Girish19
7 Replies

4. Shell Programming and Scripting

Want to terminate command execution when string found in the command output

Hi Experts, I am very much new to linux scripting, I am currently working on reducing my manual work and hence writing a script to automate few task. I am running below command to snmpwalk the router.. snmpwalk -v 3 -u WANDL_SU -a MD5 -A vfipmpls -x DES -X VfIpMpLs -l authPriv... (19 Replies)
Discussion started by: Hanumant.madane
19 Replies

5. Shell Programming and Scripting

not found message

I am trying to execute a script called tfile.sh in a bash shell in solaris and it throws up the following message I am getting the required output after this message. How do i get the message to disappear. Can someone please point out my mistake in the script? Thanks in advance ... (13 Replies)
Discussion started by: goddevil
13 Replies

6. Shell Programming and Scripting

not found message

I am executing the following script in a bash shell in solaris and it throws up the following message : But i get the output that i require nevertheless. Can anyone please spot what is causing the warning and how do i get it go away? VAR1="e6842w2334f76figtl5.systems.grp" if 76fig`... (2 Replies)
Discussion started by: goddevil
2 Replies

7. Shell Programming and Scripting

How to grep for message and if found display filename?

Hi i'm new to the forum and was hoping someone could help me with the following query. I do alot of testing and have hundreds of log files output. I have a script (someone else wrote) which finds all the passed and failed logs and puts a number in a column onto a webpage: e.g: Pass ... (4 Replies)
Discussion started by: defamer
4 Replies

8. Shell Programming and Scripting

why the message not found in the file

Hi, I am a newbie for shell programming and met some question about redirect output to a file. See the details. #!/usr/bin/sh ... ./doSomething.pl >> RAW_DATA echo "testing is done !" >> RAW_DATA Descirption: doSomething.pl do a bit complex things and output some message. I append... (3 Replies)
Discussion started by: programmerBegin
3 Replies

9. Shell Programming and Scripting

Function not found message

I have shell script as below: #!/bin/ksh #set -xv function set_variable { VARIABLE_NAME=$1 CURRENT_PATH=`pwd` if ; then echo "\nconfiguration_file.lst file not found in $CURRENT_PATH/common/common_scripts" exit 1; fi VARIABLE_COUNT=`cat... (2 Replies)
Discussion started by: findprakash
2 Replies

10. Shell Programming and Scripting

Return a message when a file is not found

Hi there, I am writing a script to look for tmp log files that have not been access within the last 10 days. I am using the follwing command within the script: find /var/tmp -name *log -atime -9 ¦xargs What I would like to be able to do would be to display a message if there is no... (3 Replies)
Discussion started by: lodey
3 Replies
Login or Register to Ask a Question