06-29-2003
Multiple exec command s in a script
Hi everyone,
I've been racking my brains for ages on this and need your help/advice.
I am writing a script that is reading in file to process and putting them into a temporary file. The loop starts and the script gets the first file name, does what i needs to do (copy it) and then returns to the top of the loop for the next file. Due to the nature of the system While inside the read line loop I have to get the next sequence number from another file which is generated by an export of an oracle table. This is then appeneded to the filename.
The problem here is that as soon as I try and read in the sequence number any subsequent files are blank. The code im using is
ifdtime=`date +%d%m%y%H%M` ; export ifdtime
LOG_FILE="/test/ohms/jobs/log/if.log" ; export LOG_FILE
LOGDIR="/test/ohms/jobs/log" ; export LOG_DIR
LOCKFILE=/tmp/KSJOBLOCK_${ORACLE_SID} ; export LOCKFILE
FILESIN=/servintftest/input/orders ; export FILESIN
runtime=`date "+%H:%M"`
rundate=`date "+%d/%m/%y"`
>$LOG_FILE
## Functions - the 2 reads are becuase oracle generates a blank line at start
get_seqno ()
{
exec < /home/interfac/scripts/seq.num;
read mark
read mark
seqno=$mark
echo $seqno
}
## Check to see if any files exist if not then abort the interface
if [ `ls -1 /servintftest/input/orders/ORDER* | wc -l` = 0 ]
then
echo "ERROR: No Files Received"
echo "${ifdtime} : ERROR: No Files Received" >>$LOG_FILE
exit
fi
## Files must exist if we got this far so read all filenames into a temp file
rm $LOGDIR/ohms_files
>$LOGDIR/ohms_files
ls -1 $FILESIN/ORDER*|cut -c28- >> $LOGDIR/ohms_files
## Now that we have the list lets process the files one by one
exec < $LOGDIR/ohms_files;
while read line
do
set - $line
## Get the last sequence number from the external system table
get_seqno
## Now copy the file but change the filename to ohmsjobs and seq no
echo "Copying file..."
cp -p $FILESIN/$1 /test/ohms/input/ohmsjobs.${seqno}
#cp -p /test/ohms/input/$1 /test/ohms/jobs/backup/ohmsjobs.${seqno}.${ifdtime}
if [ -f /test/ohms/input/ohmsjobs.${seqno} ]
then
echo "${ifdtime} : OHMS file copied $1 renamed to ohmsjobs.$seqno" >> $LOG_FILE
echo "${ifdtime} : OHMS file copied $1 renamed to ohmsjobs.$seqno"
sleep 5
#rm $FILESIN/$1fi
## Interface must have completed and a backup copy has been taken so delete
#rm /test/ohms/input/$1
done
Any help you can give would be appreciated
Regards,
Mark
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
With a awk script i create a "adduser line"
$ cat /tmp/tmp.ldif | awk -f ldif2adduser.awk
adduser --uid 1002 --gid 1000 --gecos "ROUSSIN Guy" --home /homeL/guy --shell /bin/bash --disabled-password guy
If i cut and paste this line, all is fine. But in a shell script i get errors :
... (2 Replies)
Discussion started by: guyr
2 Replies
2. Shell Programming and Scripting
Hi,
I want to write the shell script to change multple file name (the file name is get from DB)
e.g. cp db1.txt file1_new.txt
cp db2.txt file2_new.txt
cp db3.txt file3_new.txt
I have write the script like this:
VAR=`sqlplus -s $LOGON @<<ENDOFTEXT
set termout off
... (0 Replies)
Discussion started by: jackyntk
0 Replies
3. Shell Programming and Scripting
Hello All,
Is there a way to make exec do a couple of operations on a single input from find?
For example,
find . -type d -exec ls -l "{}" ";"
I would like to give the result of each "ls -l" in the above to a wc. Is that possible?
I want to ls -l | wc -l inside exec. How do I... (1 Reply)
Discussion started by: prasanna1157
1 Replies
4. Shell Programming and Scripting
I'm trying to execute something like this:
exec perl -i -pe 's/\015/\012/g' '${file}'
in my expect script and I get:
error "invalid command name \"perl\".
however, if I run
perl -i -pe 's/\015/\012/g' "/Users/Shared/menu-items.txt"
directly in my terminal, it runs fine. I'm an... (4 Replies)
Discussion started by: dpouliot
4 Replies
5. Shell Programming and Scripting
I have the following bash script lines in a file named test.sh.
#!/bin/bash
#
# Write Date to cron.log
#
echo "Begin SSI Load $(date +%d%b%y_%T)"
#
# Get the latest rates file for processing.
#
d=$(ls -tr /rms/data/ssi | grep -v "processed" | tail -n 1)
filename=$d
export filename... (3 Replies)
Discussion started by: ginowms
3 Replies
6. UNIX for Dummies Questions & Answers
Hi all,
Am wanting to do a ls -l of the files and do a cat of it at the same time, ideally, I am hoping that the following work but obvisouly it is not working to what I am wanting it to ... hu hu hu :wall:
find . -name "BACKUP_TIMESTAMP.log" -exec "ls -l basename {} ; cat {}" \;
... (1 Reply)
Discussion started by: newbie_01
1 Replies
7. Shell Programming and Scripting
Guru's,
I want to make a use of "exec" command in my script and want to check return code of executing script, but as you know exec command will terminate current processID and comeout and will trigger new one, i am unable to check return code of script and not able to run a scrpit after exec. ... (2 Replies)
Discussion started by: pawar.atul28
2 Replies
8. Programming
hi all,
i have devised a script that starts in /restored/ and in there, there are a lot of sub folders called peoples names and in the sub folders are files/folders and it deletes the data in the sub folders BUT not the sub folder itself and it should then touch a file in all the sub folders... (3 Replies)
Discussion started by: robertkwild
3 Replies
9. Programming
hi all,
i want to monitor the progress of a find and exec command, this is the code i use -
find . -type f -exec md5sum {} \; >> /md5sums/file.txt
this command works and produces a text file with all the md5sums but while running it doesnt show the progress
is there anyway i can do this... (4 Replies)
Discussion started by: robertkwild
4 Replies
10. Shell Programming and Scripting
Hello.
From a script, a command for a test is use :
find /home/user_install -maxdepth 1 -type f -newer /tmp/000_skel_file_deb ! -newer /tmp/000_skel_file_end -name '.bashrc' -o -name '.profile' -o -name '.gtkrc-2.0' -o -name '.i18n' -o -name '.inputrc'
Tha command... (3 Replies)
Discussion started by: jcdole
3 Replies
tclsh(1) Tcl Applications tclsh(1)
__________________________________________________________________________________________________________________________________________________
NAME
tclsh - Simple shell containing Tcl interpreter
SYNOPSIS
tclsh ?-encoding name? ?fileName arg arg ...?
_________________________________________________________________
DESCRIPTION
Tclsh is a shell-like application that reads Tcl commands from its standard input or from a file and evaluates them. If invoked with no
arguments then it runs interactively, reading Tcl commands from standard input and printing command results and error messages to standard
output. It runs until the exit command is invoked or until it reaches end-of-file on its standard input. If there exists a file .tclshrc
(or tclshrc.tcl on the Windows platforms) in the home directory of the user, interactive tclsh evaluates the file as a Tcl script just
before reading the first command from standard input.
SCRIPT FILES
If tclsh is invoked with arguments then the first few arguments specify the name of a script file, and, optionally, the encoding of the |
text data stored in that script file. Any additional arguments are made available to the script as variables (see below). Instead of
reading commands from standard input tclsh will read Tcl commands from the named file; tclsh will exit when it reaches the end of the
file. The end of the file may be marked either by the physical end of the medium, or by the character, "