logic for executing defined seq in file and cmd in file

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting logic for executing defined seq in file and cmd in file
# 1  
Old 09-05-2009
logic for executing defined seq in file and cmd in file

I have four files a,b,c,d which need to contain certain in the sequence a, b, c ,d , each file command which needs to be executed,

what i m in need is that to executed file and cmd in the defined order and if any of the command FAIL or throw ERROR, it script shud come out telling which file and which ?

quite I m digging deep still didn't found correct way yet
# 2  
Old 09-05-2009
Originally Posted by tarunn.dubeyy
quite I m digging deep still didn't found correct way yet
Since you haven't shown how deep you've dug, I shall assume that you have familiarity with the basic commands and concepts.

Here's what you may want to do:
- Ensure that each script returns a consistent exit code that defines success or failure.
- Display the scripts in sorted order using ls and sort, since the sequence of execution is the same as sorted order.
- Use a for loop to loop through them and source them, one per iteration.
- Test the exit code $? right after the execution.
- If the exit code indicates failure, print the script name and break out of the loop.

# 3  
Old 09-06-2009
thxs tyler_durden for idea this how I implement it

looks good but I have given seq of file in automate , redirected the error in /var/tmp/error file but , is it possible to find to line no./ cmds in the file have the thrown the error which we getting in /var/tmp/error here is code

for i in `cat automate`
ksh +x $i 2>/var/tmp/error
if [ $? -ne 0 ];then
echo "+++++++++++++++++++++++++++"
echo "FOLLOWING SCRIPT IS FAILED see file /var/tmp/error"
echo $i
echo "+++++++++++++++++++++++++++"
#exec 2>>/var/tmp/error
# 4  
Old 09-06-2009

Last edited by Scrutinizer; 09-06-2009 at 11:13 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to replace matching words defined in one file on another file?

I have file1 and file2 as shown below, file1: ((org14/1-131541:0.11535,((org29/1-131541:0.00055,org7/1-131541:0.00055)1.000:0.10112,((org17/1-131541:0.07344,(org23/1-131541:0.07426,((org10/1-131541:0.00201,org22/1-131541:0.00243)1.000:0.02451, file2: org14=india org29=america... (5 Replies)
Discussion started by: dineshkumarsrk
5 Replies

2. UNIX for Beginners Questions & Answers

How to sum value of a column by range defined in another file awk?

I have two files, file1.table is the count table, and the other is the range condition file2.range. file1.table chr start end count N1 0 48 1 N1 48 181 2 N1 181 193 0 N1 193 326 2 N1 326 457 0 N1 457 471 1 N1 471 590 2 N1 590 604 1 N1 604 752 1 N1 752 875 1 file2.range... (12 Replies)
Discussion started by: yifangt
12 Replies

3. Shell Programming and Scripting

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies

4. Programming

Use #if not defined with OR boolean logic in preprocessor directives

I am currently using Linux CentOS and programming in FORTRAN 90 using Portland 7.1 compiler. I am able to set in the preprocessor directives a flag called TEST. when I go to use logic in my code i can write #ifdef TEST execute something #endif Furthermore, if I want to negate the... (2 Replies)
Discussion started by: prodigious8
2 Replies

5. Shell Programming and Scripting

Need an automated pre-defined file pickup method

Hi Gurus, I need to develop a script which picks the files in a pre-defined order. The files from monday-friday will be named as abc_01_20130923 as monday's file and abc_02_20130924 as tuesday's..so..so forth till friday's which will be named as abc_05_20130927.It repeats over for the... (3 Replies)
Discussion started by: vikramgk9
3 Replies

6. Shell Programming and Scripting

Defined Variable from text file

Hi Guys, I have one text file ABC.txt...It have 3 lines List=/home/klk/dir/ABC.txt Leajnk123 KJUHIO1234 IJOKIJ7676 I want use as different variable of each line.Just like X=firstline Y=Secound Line Z=Third Line (4 Replies)
Discussion started by: asavaliya
4 Replies

7. Programming

how to add user defined tag in a mp3 file?

Hai all, Can anyone explain me about how to add an user defined tag in an mp3 file using MP3::Tag module in perl? (0 Replies)
Discussion started by: thillai_selvan
0 Replies

8. Shell Programming and Scripting

sorting a fixed width seq file

I have a file like this... 2183842512010-11-25 15379043 453130325 2386225062010-11-30 4946518 495952336 2386225062010-11-30 4946518 495952345 2386225062010-11-25 262066688 -516224026 2679350512010-11-25 262066688 -516224124 3196089062010-11-25 262066688 203238229... (5 Replies)
Discussion started by: issaq84mohd
5 Replies

9. Emergency UNIX and Linux Support

Functions defined in header / cpp file behaves different

File: A.h class A { public: struct x X; int show() { x.member_variable ? 0: -1; } }; Now if A.cpp is complied which includes A.h (which is actually in a huge project space) we see that x.member_variable value is not as expected. But if remove the show() method and place... (4 Replies)
Discussion started by: uunniixx
4 Replies

10. Shell Programming and Scripting

Reading file names from a file and executing the relative file from shell script

Hi How can i dynamically read files names from a list file and execute them from a single shell script. Please help its urgent Thanks in Advance (4 Replies)
Discussion started by: anushilrai
4 Replies
Login or Register to Ask a Question