Solved

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

Posted on 2006-07-20
14
675 Views
Last Modified: 2013-12-27
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
Comment
Question by:chrismurr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 3
14 Comments
 
LVL 10

Assisted Solution

by:Nukfror
Nukfror earned 250 total points
ID: 17148816
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
 
LVL 10

Expert Comment

by:Nukfror
ID: 17148829
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
 

Author Comment

by:chrismurr
ID: 17148864
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:Nukfror
ID: 17149524
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
 
LVL 48

Accepted Solution

by:
Tintin earned 250 total points
ID: 17149919
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
 
LVL 10

Expert Comment

by:Nukfror
ID: 17150628
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
 
LVL 10

Expert Comment

by:Nukfror
ID: 17150637
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
 
LVL 48

Expert Comment

by:Tintin
ID: 17150660
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
 

Author Comment

by:chrismurr
ID: 17153285
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
 

Author Comment

by:chrismurr
ID: 17153302
BTW, this cannot be executed as root either
0
 
LVL 10

Expert Comment

by:Nukfror
ID: 17153383
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
 

Author Comment

by:chrismurr
ID: 17156550
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
 
LVL 48

Expert Comment

by:Tintin
ID: 17164235
Please do

ksh -x connect_bss.ksh

and post the results.
0
 

Author Comment

by:chrismurr
ID: 17175194
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question