• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 697
  • Last Modified:

Swiched user from CSH to KSH in passwd file but user cannot execute .ksh files. how to fix this. Solaris 8

I have a user that needed to run in the ksh enviroment.  My Solaris is rusty, so I changed the passwd file to put him into the ksh enviroment at login.  the problem is, when he tries to execute a file from a sub directory of his home directory he gets the following error.

ksh: connect_bss.ksh: not found

now, I have tried executing it as ./connect_bss.ksh with no luck.  same error

I have performed the following command

PATH=$PATH:/usr/bin:/home/omc/FPrint/BSS

the path changes to
$ echo $PATH
/usr/bin:::/usr/bin:/home/omc/FPrint/BSS

but still no luck, same error.  there is no .profile in his /home/omc directory either.

can anyone guide me through fixing this, I need this user to be able to execute ksh scripts from any subdirectory he created under /home/omc without issue.
0
chrismurr
Asked:
chrismurr
  • 6
  • 5
  • 3
2 Solutions
 
NukfrorCommented:
Assuming the file is in this user's home directory run this:

cd /<Home dir of user>
find . -name connect_bss.ksh -print

This will tell you if the file is in the user's home directory or not.

On a secondary note, you didn't have to change the user's default shell from CSH to KSH necessarily.  A good programming standard for any admin or user is to include the proper link loader syntax at the top of all scripts.  So for a ksh script the proper first line is:

#!/bin/ksh

For csh its:

#!/bin/csh

This way the user's default shell can be anything.  When the link loader see's a text file that executable, it checks for this line as the first line in the script.  If the line exists, it will fork/exec that script to interpret the script to run it.
0
 
NukfrorCommented:
Ahh, and allowing a user to execute a script from *any* directory is a very *bad* policy.  The users should put some sort of controls around where various files are placed.  A good example is to make maybe a bin directory to hold his executable scripts.
0
 
chrismurrAuthor Commented:
they only execute scripts from a sub directory of their home directory.  I has put them back to the csh as the default and tried again, the file can be found in the directory but when you try to exeute it, it fails with the error above.  I did check the script and it is properly programmed with the #!/bin/ksh at the top.

any other ideas?  
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
NukfrorCommented:
So the script exists in say directory /home/thisuser/subdirectory. If you execute:

cd /home/thisuser/subdirectory
./connect_bss.ksh

You get this error ?

ksh: connect_bss.ksh: not found

Has you tried:

cd /home/thisuser/subdirectory
ksh connect_bss.ksh

Is the script executable ?

ls -l connect_bss.ksh

If not, run this:

chmod +x connect_bss.ksh

and try this again:

./connect_bss.ksh
0
 
TintinCommented:
The only way you'd get the error

ksh: connect_bss.ksh: not found

is, if in fact the file is missing.

Show us the results of

cd /home/omc/FPrint/BSS
ls -l

od -c connect_bss.ksh
0
 
NukfrorCommented:
Actually I don't think so.  If they are using the link loader to fork/exec the shell and if the user's default shell is CSH, then how could CSH know that the missing file's link loader interpreter is supposedly to be KSH - when the file doesn't exist.
0
 
NukfrorCommented:
Actually I misspoke, CSH doesn't do anything with the link loader ... then how could the *link loader* know that the missing file's needed shell is supposed to be KSH when the file doesn't exist.
0
 
TintinCommented:
You get the error if your current shell is ksh, eg:

$ echo $0
ksh
$ ls -l
total 0
$ ./connect_bss.ksh
ksh: ./connect_bss.ksh:  not found
0
 
chrismurrAuthor Commented:
here is the results trying to run the file along with the path information for this user.

statsdo:/home/omc/FPrint/BSS <47> (omc) % pwd
/home/omc/FPrint/BSS
statsdo:/home/omc/FPrint/BSS <48> (omc) % connect_bss.ksh
connect_bss.ksh: Command not found
statsdo:/home/omc/FPrint/BSS <49> (omc) % ./connect_bss.ksh
./connect_bss.ksh: Command not found
statsdo:/home/omc/FPrint/BSS <50> (omc) % /home/omc/FPrint/BSS/connect_bss.ksh
/home/omc/FPrint/BSS/connect_bss.ksh: Command not found
statsdo:/home/omc/FPrint/BSS <51> (omc) % ls -l
total 34
-rwxrwxrwx   1 omc      omc         2072 Jul 17 16:27 bsc_cpu.ksh
-rwxrwxrwx   1 omc      omc         4963 Jul 17 16:39 connect_bss.ksh
-rwxrwxrwx   1 omc      omc         4963 Jul 17 16:55 connect_bss_day.ksh
-rw-r--r--   1 omc      omc           52 Jul 21 02:00 cron.log
-rw-r--r--   1 omc      omc          140 Jul 17 16:28 marker.dia
-rw-r--r--   1 omc      omc          140 Jul 17 16:28 marker.dia~
drwxrwxrwx   2 omc      omc          512 Jul  5 16:22 results
statsdo:/home/omc/FPrint/BSS <52> (omc) %

echo $PATH
/bin:/usr/bin:/usr/sbin:/etc:/opt/SUNWconn/bin:/usr/ucb:/CMN/base/exe:/OMC/base/exe:/MD/base/exe:/MD/base/tools/exe:/CMN
/base/tools/exe:/OMC/base/tools/exe:.:/usr/openwin/bin:/usr/openwin/bin/xview:/usr/openwin/lib:/usr/dt/bin:/opt/SUNWmfwm
/bin:/opt/SUNWits/bin:/opt/SUNWconn/bin:/usr/ccs/bin:/opt/Acrobat3/bin:/opt/sybase/bin:/home/omc:/home/omc/bin


I have even tried to copy the file to the /home/omc/bin directory (which is in the path) and still get the same error.

still doesnt make any sense, this shouldnt be that big of an issue. i can execute the file is 'sh connect_bss.ksh' but because it calls other scripts, it terminates unexpectantly.  
0
 
chrismurrAuthor Commented:
BTW, this cannot be executed as root either
0
 
NukfrorCommented:
Can you do the following while you're in /home/omc/FPrint/BSS:

head connect_bss.ksh

Did you mean to say "sh connect_bss.ksh" or should the "sh ..." portion be "ksh ..." ?
0
 
chrismurrAuthor Commented:
no I meant "sh connect_bss.ksh"

 head connect_bss.ksh
#!/bin/ksh
###### Variable input from install.ksh or setup.ksh file ######
shortclli=CHTNWV27DS1
#ftp_address="47.234.32.32"
server="serv1"
###### Get date and figure out date_directory to get the actual files ######
year=`date +'%Y'`
month=`date +'%m'`
conf_date=`date +'%Y''%m''%d'`
######
0
 
TintinCommented:
Please do

ksh -x connect_bss.ksh

and post the results.
0
 
chrismurrAuthor Commented:
sorry I didnt get back sooner.  the problem wasnt with the shell at all.  the user ftp's the file from a linux Fedora server and when the transfer happens, every line in the script has a ^M at the end of it.  Effectively corrupting the script all together.  it wasnt a shell problem after all.

I will split the points for you two for all the effort.

thanks,
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 6
  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now