Operating System - HP-UX
1833792 Members
2220 Online
110063 Solutions
New Discussion

Script file creation problem

 
SOLVED
Go to solution
David Land
Frequent Advisor

Script file creation problem

I have a fairly simple problem that I seem to not be able to get figured out.
I have created a simple script that displays contents of a file. The problem I
am running into seems to stem from another problem I had run into before, I think.

After I created the file I did a chmod 777 on it. Then everytime I tried to run
the script, I receive "sh: scriptname: not found." But if I put a ./scriptname, it works.
I decided to create a test user to see if the problem was with my user id and
everything worked correctly.

The only difference I see between my actual user and my test user is the Start-Up
Program in SAM.

This is where the earlier problem I ran into must be the factor. I had to change the
Start-Up Program from /usr/bin/sh to /sbin/sh so I could make FTP work. I do not have
an /etc/ftpd/ftpusers file so I know that cannot be the problem.

My question is this, 1) Why am I having problems running this simple script that
I created and 2) Do I really need the Start-Up Program to list /sbin/sh for this
user id to FTP?
8 REPLIES 8
RAC_1
Honored Contributor

Re: Script file creation problem

What do you use in your script??

/sbin/sh or /usr/sbin/sh??
what are the perms on /sbin/sh

Anil
There is no substitute to HARDWORK
Mark Greene_1
Honored Contributor
Solution

Re: Script file creation problem

At some point the PATH variable is getting reset to not include the current directory. Do test of both scenarios to capture the output from "env" and see which one has a "." in the PATH and which one does not.

mark
the future will be a lot like now, only later
Siddhesh
Advisor

Re: Script file creation problem

What is the name you have given to your script? Make sure that you should not give any `commandname` to your script.
Because when you try to execute your script, your shell searches the PATH for the `scriptname` and if the commandâ s PATH comes before your script's PATH, then your shell will try to execute the `command` instead of your script.
And that `command` must be requiring Root privileges to run(/sbin/sh is a rootâ s shell).
Your script works when you give ./ that is because of the same reason. Since you specify the current directory and run your script, it does not search the PATH for the `scriptname` and runs it from the current directory.

Please let me know whether it resolves your issue.

Sid
David Land
Frequent Advisor

Re: Script file creation problem

Mark, you were right. The . was not in my users PATH statement but was in the test PATH.
Govind_3
Regular Advisor

Re: Script file creation problem

/sbin/sh should be for roots default shell. I would suggest you to use /usr/bin/sh for ordinary users. In anycase the problem is your initialization files, I think, check your .profile and .login for these users, its defintely the $PATH variable which is not including "." the current directory in the 1st case (where it isnt working) and it is being included in the seocnd case where its working.
-Good luck
Govind
David Land
Frequent Advisor

Re: Script file creation problem

Last question, since the "." seemed to be the problem, what is the . actually used for?
Pete Randall
Outstanding Contributor

Re: Script file creation problem

The "." stands for the current directory or PWD.


Pete

Pete
Mark Greene_1
Honored Contributor

Re: Script file creation problem

"." is current directory, and ".." is parent directory. If you go to somewhere like /var/spool and do an ls -la|pg, at the top of the listing you'll see them. You can use them as an indirect directory reference, like "cd ..".

mark
the future will be a lot like now, only later