running a script in different directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting running a script in different directories
# 1  
Old 02-19-2009
running a script in different directories

hi,
I have a peculiar problem
I am working in bash shell
There is one particular directory in my unix box
For the scripts present in that directory, if i put sh <script name>
it is working fine
if i put ksh <script name> the corresponding script is not even executing

but apart from that directory if i put the script in my home directory and run the script using the command ksh <script name> it is working fine

I am wondering what could be reason for the same

can any one plz help how to solve this issue

thanks in advance
# 2  
Old 02-19-2009
How do you know the script does not run?
And please show us this script.
# 3  
Old 02-19-2009
i created a script called tst.ksh
this is the script info.

#!/bin/ksh
date

If i run the script in home directory using the command ksh tst.ksh it is working fine

If i run the same script in some other directory (e.x. source directory) using the command ksh tst.ksh it is not executing but if i try to find the return code using echo $? it is returning 0
in the same directory i tried executing using sh tst.ksh it is displaying the result

what will the reason
# 4  
Old 02-20-2009
try like this :

./tst.ksh

otherwise add set -x in the begining of the script and see the result
#!/bin/ksh
set -x
date
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running program and output files in specific directories

I have been running a program mseed2sac using the following command cd IV find . -type f -exec /swadmin/mseed2sac '{}' \; The problem is that I end up with a lot of files in directory IV. Instead I would like to select the designator HHZ, create a directory IV.SAC and all the files output... (11 Replies)
Discussion started by: kristinu
11 Replies

2. Shell Programming and Scripting

Why script is running sometimes and not running sometimes?

Hi, I have a script which does couple of database connection and run some SELECT queries to get some output in the file. I am surprised to see :eek: that when i run my script some times it gives the desired out put and sometimes it shows some error :confused: . Suppose if i execute it say... (3 Replies)
Discussion started by: Sharma331
3 Replies

3. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

4. UNIX for Dummies Questions & Answers

Running a script from another script by moving directories

I have created this script and does not seem to be behaving well. Basically I am in a directory, I just want to do down two directories, run the script georom_replaceText.tcsh This will produce a file in the subdirectory, which I then run. Finally go back to where I started. Afterwards I... (4 Replies)
Discussion started by: kristinu
4 Replies

5. Shell Programming and Scripting

Automate the process of running jobs on several directories consecutively

Hi, I have about 10 directories in which I run the same code. But this code is only run in a directory when the computation in the previous directory was successful (explained below). My directories are named as : VF_50, VF_100, VF_150, VF_200............. As you can see the number after _... (6 Replies)
Discussion started by: lost.identity
6 Replies

6. Shell Programming and Scripting

Running find in all directories except one

hi, in a directory called dir1 with subdir : dir11 dir12 dir13 dir14 i'm using this kind of request in ksh: find /dir1 -name '*txt' |wc -l i want now to run the same request but without going down in the subdir dir14 is there a simple way to do that ? if not what do you... (4 Replies)
Discussion started by: Nicol
4 Replies

7. Shell Programming and Scripting

Script for parsing directories one level and finding directories older than n days

Hello all, Here's the deal...I have one directory with many subdirs and files. What I want to find out is who is keeping old files and directories...say files and dirs that they didn't use since a number of n days, only one level under the initial dir. Output to a file. A script for... (5 Replies)
Discussion started by: ejianu
5 Replies

8. Shell Programming and Scripting

Bash script: issue changing directories in script

I am working on a script that checks two arguments at the command line. The first argument is a search pattern, the second can be a file or a directory, if it is a file a second script is called that checks it for the search pattern. If the second argument is a directory, it checks for the search... (5 Replies)
Discussion started by: Breakology
5 Replies

9. Solaris

Running from Shell Vs running from RC script

Hi, i have a script which need to do behave differently when run as a startup process from init.d/ rc2.d script and when run manually from shell. How do i distinguish whether my script is run by init process or by shell?? Will the command /proc/$$/psinfo | grep "myscript" work well???... (2 Replies)
Discussion started by: vickylife
2 Replies
Login or Register to Ask a Question