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
662 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
  • 6
  • 5
  • 3
14 Comments
 
LVL 10

Assisted Solution

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

Expert Comment

by:Nukfror
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 48

Expert Comment

by:Tintin
Comment Utility
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
Comment Utility
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
Comment Utility
BTW, this cannot be executed as root either
0
 
LVL 10

Expert Comment

by:Nukfror
Comment Utility
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
Comment Utility
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
Comment Utility
Please do

ksh -x connect_bss.ksh

and post the results.
0
 

Author Comment

by:chrismurr
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

762 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now