Sponsored Content
Full Discussion: Error Trapping
Top Forums Shell Programming and Scripting Error Trapping Post 302576573 by m.d.ludwig on Friday 25th of November 2011 09:01:27 AM
Old 11-25-2011
If ls "fails" -- which I believe to mean it does not match the "${SegList}.DAT.${Datelist}.GZ" pattern -- there is no output, the file is empty.

I am trying to figure out what you are trying to do. First off, I indented your code (which makes it much easier to read):
Code:
while read SegList; do
    if test -s ${SourceFile_Path}/${Segment_List_Temp}; then
        ls -r -1 ${FTP_Path}/${SegList}.DAT.${Datelist}.GZ | cut -d '.' -f2 >> ${SourceFile_Path}/${List_Temp}
    else
        ls -r -1 ${FTP_Path}/${SegList}.DAT.${Datelist}.GZ | cut -d '.' -f2 > ${SourceFile_Path}/${List_Temp}
     fi
done < ${Segmentlist_Path}/${Segment_List}

Inside the loop, the only difference I see is that ${List_Temp} is appended to if ${Segment_List_Temp} exists and has data, otherwise ${List_Temp} is overwritten. This can be simplified by removing ${List_Temp} when ${Segment_List_Temp} does not exist or has no data, and then append to ${List_Temp}, as follows:
Code:
while read SegList; do
    if ! test -s ${SourceFile_Path}/${Segment_List_Temp}; then
        rm -f ${SourceFile_Path}/${List_Temp}
    fi

    ls -r -1 ${FTP_Path}/${SegList}.DAT.${Datelist}.GZ | cut -d '.' -f2 >> ${SourceFile_Path}/${List_Temp}
done < ${Segmentlist_Path}/${Segment_List}

${Segment_List_Temp} is not otherwise modified by the script, so it can be pulled out of the loop, as can the cut:
Code:
if ! test -s ${SourceFile_Path}/${Segment_List_Temp}; then
    rm -f ${SourceFile_Path}/${List_Temp}
fi

while read SegList; do
    ls -r -1 ${FTP_Path}/${SegList}.DAT.${Datelist}.GZ
done < ${Segmentlist_Path}/${Segment_List} \
| cut -d '.' -f2 >> ${SourceFile_Path}/${List_Temp}

BTW, what is the value of ${Datelist}? Is it a pattern? Also, does either ${FTP_Path} or ${SeqList} contain "."? If not, then the output file will contain nothing but lines of "DAT".

I do have to ask -- what is the intention of this script?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sql error code trapping

Hello #!bin/ksh sqlplus -s system/manager < |grep '^ORA' |uniq select * from kk; set echo on show spool on end; / EOF save test.sh sh test.sh results ORA-00942: table or view does not exist (3 Replies)
Discussion started by: xiamin
3 Replies

2. UNIX for Dummies Questions & Answers

ftp error trapping

Hi I'm hoping I could get some help on the following. I'm writing a script which will in turn create an ftp script then excecute it. eg echo "user $user $pass" > $script echo "cd $remote_dir" >> $script echo "bi" >> $script echo "mput $file" >> $script echo "bye" >> $script ftp -n -i $ip... (1 Reply)
Discussion started by: Bab00shka
1 Replies

3. UNIX for Dummies Questions & Answers

ftp error trapping

I have written a UNIX script that will automatically ftp a file to a server. The problem is when I missed enter information w/in the .txt file that contains the userid/password and what file to transfer, I had no way of capturing the failuer of the file transfer. I verified w/in the script that the... (1 Reply)
Discussion started by: dhawkjrscripter
1 Replies

4. Shell Programming and Scripting

Error Trapping

Hi, Can anybody tell me how to error trap an empty line. If i am asked for a password and I hit enter without entering any text, how do i display an error? Thanks Kev (6 Replies)
Discussion started by: kev112
6 Replies

5. Shell Programming and Scripting

rcp error trapping in rsh

I am writing a program which is something like below: rsh host1 "rcp file dest:directory" I am running this script from a machine host2. host1 has rlogin configuration for host2. but, dest machine has no rlogin configuration for host1 and fails on remote calls. Could anyone tell me how... (2 Replies)
Discussion started by: vvejendla
2 Replies

6. Shell Programming and Scripting

Error trapping in parent/child scripts

Greets all. I'm using Slackware 12.0 with the bash shell. Calling my scripts with /bin/sh... I'm building gnome-2.18.3 and I have all my build scripts ready and working but I'm calling them from a parent script which executes each child/build script in a certain order (for loop). I have "set... (6 Replies)
Discussion started by: madpenguin
6 Replies

7. Shell Programming and Scripting

Searching and FTP error trapping

This is gonna sound dumb but... 1 It seems that I cannot use the search function here properly. In researching to find a solution to an FTP error trapping issue, I go to the search option in the forum and use FTP as a search term and ask it to select all forums to search in..... I get no... (2 Replies)
Discussion started by: Bartman
2 Replies

8. Shell Programming and Scripting

trapping error for a grep in for a loop

How can I trap and print "cannot find the pattern" when the grep is unable to find the specified pattern in the file using the for loop below ? Any help would be appreciated. bash3.4> cat test_file apple orange pineapple blackberry script: for x in `grep -n "mango" test_file... (4 Replies)
Discussion started by: jville
4 Replies

9. Shell Programming and Scripting

curl error trapping in ksh

I hope that I can trap curl errors, and have my shell script error out and quit if curl has any sort of problem. For example, I have the following command in my shell script: curl --trace -n -v --ftp-ssl ftp://xxx.xxx.xxx.xxx:2122 --user user:password -o /tmp/file.txt Works great, except... (2 Replies)
Discussion started by: prestonatwork
2 Replies

10. Shell Programming and Scripting

Trapping the error during copy

I have a requirement: During copy command for example: cp -rf <sourceDir> <destinationDir> this command may fails for many reasons like: 1. source or destination directory does not exist 2. destination directory does not have sufficient space 3. directories are not mounted ... Or may... (3 Replies)
Discussion started by: ambarginni
3 Replies
SEQDIAG(1)						      General Commands Manual							SEQDIAG(1)

NAME
seqdiag - generate sequence-diagram image file from spec-text file. SYNOPSIS
seqdiag [options] file DESCRIPTION
This manual page documents briefly the seqdiag commands. seqdiag is generate sequence-diagram image file from spec-text file. OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. For a complete description, see the Info files. --version show program's version number and exit -h, --help show this help message and exit -a, --antialias Pass diagram image to anti-alias filter -c FILE, --config=FILE read configurations from FILE -o FILE write diagram to FILE -f FONT, --font=FONT use FONT to draw diagram -T TYPE Output diagram as TYPE format SEE ALSO
The programs are documented fully by http://tk0miya.bitbucket.org/seqdiag/build/html/index.html AUTHOR
seqdiag was written by Takeshi Komiya <i.tkomiya@gmail.com> This manual page was written by Kouhei Maeda <mkouhei@palmtb.net>, for the Debian project (and may be used by others). May 21, 2011 SEQDIAG(1)
All times are GMT -4. The time now is 11:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy