Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Running a script from another script by moving directories Post 302621021 by kristinu on Monday 9th of April 2012 04:43:59 PM
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

 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
All times are GMT -4. The time now is 05:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy