~sh script help !!~


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ~sh script help !!~
# 1  
Old 04-13-2005
MySQL ~sh script help !!~

Hi all

New to scripting , what i am trying to do is that i have a directory called test which contains series of scripts which all begin with tst*.exe and i want to run all of them by a single script on a unix platform ...
i also want to issue a command against each one of the script as mentioned above...and output data file produced with .txt extension e.g. tst123.exe will produce 123.txt, tst345.exe will produce 345.txt...etc..


how can i do this...evrybit of help much appreciated ...thanks in advance...bindy
# 2  
Old 04-13-2005
What shell are you planning to use? Also, is there an order in which you want to execute the scripts in the test directory? Are any of these scripts dependent upon another?
# 3  
Old 04-13-2005
hi google

i was think of using #!/bin/sh shell script, the scripts within the test directory do not depend on each other,the scripts are the same but with different parameters and i want to able to recognise the output from each on of them, hence the name of each outpuit file (123.txt etc)...the scripts can be executed in any order ...

thanks again for the help...bindy
# 4  
Old 04-13-2005
assuming that there are only 3 numbers in between test and .exe ... and assuming that this is not homework ...
Code:
#! /bin/ksh

for i in test*.exe
do
    inum=`echo $i | cut -c5-7`  
    $i > $inum.txt 2>&1
done

exit 0

# 5  
Old 04-13-2005
Be sure to use a full path.

Code:
for i in full/path/to/script/test*.exe

# 6  
Old 04-13-2005
hi just ice...

thanks, but no its not homewoirk, i am just bit rusty in scripting....

the test directory contains about 20 script files(*.exe each script has same commands but different embedded parameters in them ), i want a unix sh single script to run these scripts from the directory and issue a command which will generate output data file from each of the 20 scripts within the dir., and i want to able to recognise which data out put is from which script...(data file ends in *.txt file format)...hope it makes sense...waiting for response...thanks again...bindy
# 7  
Old 04-13-2005
Code:
#! /bin/ksh

cd /script_dir
for script in test*.exe
do
    inum=`echo $script | cut -c5-7`  
    $script arg1 arg2 ... > $inum.txt 2>&1
done

exit 0

Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

3. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

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

5. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies
Login or Register to Ask a Question