Running a script from another script by moving directories


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Running a script from another script by moving directories
# 1  
Old 04-09-2012
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

HTML Code:
georom_replaceText.tcsh
This will produce a file in the subdirectory, which I then run. Finally go back to where I started. Afterwards I repeat by going to another directory. The funny thing is that running the command on their own one after each other on the command line, everything seems to work without problems.

Code:
#!/bin/tcsh

cd ./geo1936/geo01n01; /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh --year=1936 *.html; ./georom14-1936.run; cd ../..
cd ./geo1936/geo01n02; /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh --year=1936 *.html; ./georom14-1936.run; cd ../..
cd ./geo1936/geo01n03; /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh --year=1936 *.html; ./georom14-1936.run; cd ../..
cd ./geo1937/geo02n01; /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh --year=1937 *.html; ./georom14-1937.run; cd ../..
cd ./geo1937/geo02n02; /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh --year=1937 *.html; ./georom14-1937.run; cd ../..

# 2  
Old 04-09-2012
@kristinu This is getting tiresome because you continue to post vague topics with no context, verging on the abstract.
Quote:
Basically I am in a directory, I just want to do down two directories, run the script
Please post your question in good unambiguous plain English (your post reads as gibberish in plain English) and make it clear what Operating System and version you are running and what Shell you are using (I worked out that is is probably tcsh but we all know that MSDOS-type file extensions have no meaning whatsoever in unix).

Back on topic:
Please post the contents of:
georom_replaceText.tcsh

Last edited by methyl; 04-09-2012 at 05:09 PM..
# 3  
Old 04-09-2012
I am working on ubuntu 11.10 and writing some tcsh scripts.

I am in directory below, with the contents displayed below:

Code:
$ pwd
/geo14htm/abstracts

$tree -fid
./tle2007
./tle2007/tle26n01
./tle2007/tle26n02
./tle2007/tle26n03
./tle2007/tle26n04
./tle2007/tle26n05
./tle2007/tle26n06
./tle2007/tle26n07
./tle2007/tle26n08
./tle2007/tle26n09
./tle2007/tle26n10
./tle2007/tle26n11
./tle2007/tle26n12
./tle2008
./tle2008/tle27n01
./tle2008/tle27n02
./tle2008/tle27n03
./tle2008/tle27n04
./tle2008/tle27n05
./tle2008/tle27n06
./tle2008/tle27n07
./tle2008/tle27n08
./tle2008/tle27n09
./tle2008/tle27n10
./tle2008/tle27n11
./tle2008/tle27n12

I also have a tcsh script

Code:
$ls *.tcsh /geo14htm/abstracts
modifyAbstracts.tcsh

$cat modifyAbstracts.tcsh
 #!/bin/tcsh
cd ./tle2007/tle26n01;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2007 *.html; ./georom14-2007.run; cd ../..
cd ./tle2007/tle26n02;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2007 *.html; ./georom14-2007.run; cd ../..
cd ./tle2007/tle26n03;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2007 *.html; ./georom14-2007.run; cd ../..
cd ./tle2007/tle26n04;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2007 *.html; ./georom14-2007.run; cd ../..
cd ./tle2007/tle26n05;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2007 *.html; ./georom14-2007.run; cd ../..
cd ./tle2007/tle26n06;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2007 *.html; ./georom14-2007.run; cd ../..
cd ./tle2007/tle26n07;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2007 *.html; ./georom14-2007.run; cd ../..
cd ./tle2007/tle26n08;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2007 *.html; ./georom14-2007.run; cd ../..
cd ./tle2007/tle26n09;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2007 *.html; ./georom14-2007.run; cd ../..
cd ./tle2007/tle26n10;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2007 *.html; ./georom14-2007.run; cd ../..
cd ./tle2007/tle26n11;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2007 *.html; ./georom14-2007.run; cd ../..
cd ./tle2007/tle26n12;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2007 *.html; ./georom14-2007.run; cd ../..
cd ./tle2008/tle27n01;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2008 *.html; ./georom14-2008.run; cd ../..
cd ./tle2008/tle27n02;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2008 *.html; ./georom14-2008.run; cd ../..
cd ./tle2008/tle27n03;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2008 *.html; ./georom14-2008.run; cd ../..
cd ./tle2008/tle27n04;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2008 *.html; ./georom14-2008.run; cd ../..
cd ./tle2008/tle27n05;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2008 *.html; ./georom14-2008.run; cd ../..
cd ./tle2008/tle27n06;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2008 *.html; ./georom14-2008.run; cd ../..
cd ./tle2008/tle27n07;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2008 *.html; ./georom14-2008.run; cd ../..
cd ./tle2008/tle27n08;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2008 *.html; ./georom14-2008.run; cd ../..
cd ./tle2008/tle27n09;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2008 *.html; ./georom14-2008.run; cd ../..
cd ./tle2008/tle27n10;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2008 *.html; ./georom14-2008.run; cd ../..
cd ./tle2008/tle27n11;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2008 *.html; ./georom14-2008.run; cd ../..
cd ./tle2008/tle27n12;  /home/chrisd/srv/sunny/hstmy/bin/tcsh/georom_replaceText.tcsh  --year=2008 *.html; ./georom14-2008.run; cd ../..

Does it make a difference whether I run the script or run them on the command line.

I am running things in this way

Code:
$ pwd
/geo14htm/abstracts
./modifyAbstracts.tcsh

georom_replaceText.tcsh 

creates the scripts

georom14-2007.run and georom14-2008.run

in the subdirectories

./tle2007/tle26n01
./tle2007/tle26n02
./tle2007/tle26n03
./tle2007/tle26n04
./tle2007/tle26n05
./tle2007/tle26n06
./tle2007/tle26n07
./tle2007/tle26n08
./tle2007/tle26n09
./tle2007/tle26n10
./tle2007/tle26n11
./tle2007/tle26n12
./tle2008/tle27n01
./tle2008/tle27n02
./tle2008/tle27n03
./tle2008/tle27n04
./tle2008/tle27n05
./tle2008/tle27n06
./tle2008/tle27n07
./tle2008/tle27n08
./tle2008/tle27n09
./tle2008/tle27n10
./tle2008/tle27n11
./tle2008/tle27n12

which I then need to run either

georom14-2007.run or georom14-2008.run

in
Code:
./tle2007/tle26n01
 ./tle2007/tle26n02
 ./tle2007/tle26n03
 ./tle2007/tle26n04
 ./tle2007/tle26n05
 ./tle2007/tle26n06
 ./tle2007/tle26n07
 ./tle2007/tle26n08
 ./tle2007/tle26n09
 ./tle2007/tle26n10
 ./tle2007/tle26n11
 ./tle2007/tle26n12
 ./tle2008/tle27n01
 ./tle2008/tle27n02
 ./tle2008/tle27n03
 ./tle2008/tle27n04
 ./tle2008/tle27n05
 ./tle2008/tle27n06
 ./tle2008/tle27n07
 ./tle2008/tle27n08
 ./tle2008/tle27n09
 ./tle2008/tle27n10
 ./tle2008/tle27n11
 ./tle2008/tle27n12

# 4  
Old 04-10-2012
Code:
$cat modifyAbstracts.tcsh
 #!/bin/tcsh

May be a mispost but there appears to be a leading space on the first line of the script which will cause the #!/bin/tcsh to be ignored.
# 5  
Old 04-10-2012
I have run the script and things are fine. And I fixed some problems. Not sure why the script failed on some instances. Anyway, I found the files with the problem and now things are working.
This User Gave Thanks to kristinu For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Archiving and moving files into directories, creating directories, etc.

how can i move "dataName".sql.gz into a folder called 'database' and then move "$fileName".tar.gz * .htaccess into a folder called 'www' with the entire gzipped file being "$fileName".tar.gz? Is this doable or overly complex. so mydemo--2015-03-23-1500.tar.gz > database -... (5 Replies)
Discussion started by: wyclef
5 Replies

2. UNIX for Dummies Questions & Answers

Moving directories

Hi Can I ask a (probably) easy question? I have a range of files in nested directories: subj_01/session_1/AAA/safe.txt subj_01/session_1/AAA/sample.txt subj_01/session_1/DDD/results.txt This is repeated for three sessions for each of subj_{01..026} Is there a way of copying the... (9 Replies)
Discussion started by: montywaite
9 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. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

5. Shell Programming and Scripting

script for reading logs of a script running on other UNIX server

Hi, I have a script, running on some outside firwall server and it's log of success or failure is maintained in a file. I want to write a script which ftp that server and reads that file and checks the logs and if failure , I will send mail notification. Please let meknow if I am not... (1 Reply)
Discussion started by: vandana.parwani
1 Replies

6. 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

7. 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

8. Shell Programming and Scripting

How to stop a script running in remote server from local script

Hi, I have googled for quite some time and couldn't able to get what exactly I am looking for.. My query is "how to stop a shell script which is running inside a remote server, using a script"??? can any one give some suggestions to sort this out. (1 Reply)
Discussion started by: mannepalli
1 Replies

9. Shell Programming and Scripting

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... (3 Replies)
Discussion started by: trichyselva
3 Replies

10. Shell Programming and Scripting

moving directories to new directories on multiple servers

Hi - I am new to unix scripts...I need to move several directories on multiple servers to new directories. (0 Replies)
Discussion started by: mackdaddy07
0 Replies
Login or Register to Ask a Question