Sponsored Content
Top Forums Shell Programming and Scripting Log file is not getting created & unable to grep error from it Post 302434610 by methyl on Saturday 3rd of July 2010 08:17:34 PM
Old 07-03-2010
You appear to be exiting the entire script if ftp returns an error code. This is before looking at $FTPLOG for the reason.
For example:
Quote:
EXITFTP=$?
if test $EXITFTP -ne 0; then echo "ERROR FTP" >> $LOG; exit 3; fi
What is in /SYSTEM/custom/data/MNP/mpgsdev/log/ftp.log ?

What is in /SYSTEM/custom/data/MNP/mpgsdev/log/error.log ?


Points about creating the ftp error log:
Quote:
ftp -n $SECONDARY 2>&1 1> $FTPLOG <<END
I'd prefer this:
Code:
ftp -n $SECONDARY 2>&1 > $FTPLOG <<END

Or preferably (if you are prepared to clear the log after each instance of ftp). I have no idea why this works better with some versions of ftp but it does.
Code:
ftp -n $SECONDARY 2>>${FTPLOG} 1>>${FTPLOG}  <<END


Comments:
1) This script could be approximately one twelfth the size by putting repeated code into functions.

2) Each if the following statements would be better written as a "while" not a "for" because they will fail for large numbers of files or filenames containing space characters:
Code:
ls pattern 2>/dev/null | while read file

Quote:
for file in `ls $PORTIN_FILE_PREFIX*$ACKPATTERN 2>/dev/null`
for file in `ls $PORTOUT_FILE_PREFIX*$ACKPATTERN 2>/dev/null`
for file in `ls $PORTIN_FILE_PREFIX*$COMPLETIONPATTERN 2>/dev/null`
for file in `ls $PORTOUT_FILE_PREFIX*$COMPLETIONPATTERN 2>/dev/null`
for file in `ls $PORTIN_FILE_PREFIX*$ERRORPATTERN $PORTIN_FILE_PREFIX*$REJECTPATTERN 2>/dev/null`
for file in `ls $PORTOUT_FILE_PREFIX*$ERRORPATTERN $PORTOUT_FILE_PREFIX*$REJECTPATTERN 2>/dev/null`
3) With most mainstream ftp implementations you can avoid holding passwords in a script by using a ".netrc" file. However because you are using "quote" I deduce that the target system is not unix.

Last edited by methyl; 07-03-2010 at 09:32 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

want to cat the latest log file created

everytime a new logfile get created at certain interval of time and i want a simple shell script program which cat the lastest log file when manually excuted (1 Reply)
Discussion started by: vkandati
1 Replies

2. Shell Programming and Scripting

I want to get the file which created the error when the find command was run

I want to get the file which created the error when the find command was run ? I am wrote a script to mail a list of files whose file size is ge than 0 and returns 0 but wen it finds a folder with only empty files it exits as 1. i need to modify it so that the return for this is also 0 (but it... (1 Reply)
Discussion started by: guhas
1 Replies

3. Shell Programming and Scripting

autosys job error file not created

Hi All Something really weird happened, I have an autosys job: insert_job: CAT_LDN_BaseCorrs job_type: c command: $$(LDNFIRC)\CAT_LDN_BaseCorrs.bat -modeldate $$MODEL_DATE -cutdate $$CUT_DATE permission: gx, mx, wx description: "Rerun=0;625;#CAT_Autosys" std_out_file:... (0 Replies)
Discussion started by: evilsmile2004
0 Replies

4. Shell Programming and Scripting

Count number of Nodes created and write it to a Log file

Dear Experts, I have to count the number of AddressRecords formed in bbc.xml file using unix script file. For example: for below pasted file, I need to write an output to a log file as "No. of Address Records Created=4". Snippet of bbc.xml:- <?xml version="1.0" encoding="UTF-8" ?> -... (1 Reply)
Discussion started by: phani333
1 Replies

5. Shell Programming and Scripting

Parsing Log File Based on Date & Error

I'm still up trying to figure this out and it is driving me nuts. I have a log file which has a basic format of this... 2010-10-10 22:25:42 Init block 'UA Deployment Date': Dynamic refresh of repository scope variables has failed. The ODBC function has returned an error. The database... (4 Replies)
Discussion started by: k1ko
4 Replies

6. UNIX for Dummies Questions & Answers

Unable to copy file using SCP (Input/output & Permission denied error)

Hi, I am facing issue while using scp. Source & target machines are Linux & HP-UX respectively. On target machine, if I fire the following command, I get error: Now if I try scp on another file, which is on the same source machine, it works fine. All directories and subdirectories... (2 Replies)
Discussion started by: Technext
2 Replies

7. Solaris

Unable to mount ext4 filesystem (created from Ubuntu) in Solaris 11

Hello everyone, I am trying to mount an ext4 filesystem which I created from Ubuntu. But mount command fails saying: prakhar@Solaris:~$ sudo mount /dev/dsk/c10t0d0p1 /mnt Password: mount: /dev/dsk/c10t0d0p1 is not this fstype And I also tried this: prakhar@Solaris:~$ fstyp... (6 Replies)
Discussion started by: Prakhar Mishra
6 Replies

8. Shell Programming and Scripting

Need Script to ZIP/SAVE & then DELETE Log file & send a mail conformation for any error

ENVIROMENT Linux: RHEL 6.4 Log Path: /usr/iplanet/servers/https-company/logs Log Format: user.log.03-15-2015 I have log4j log rotation enabled rotating files on a daily basis. The rotated logs are NOT compressed & are taking up too much space. I need a script that will run daily that... (1 Reply)
Discussion started by: admin_job_admin
1 Replies

9. UNIX for Beginners Questions & Answers

Print Error in Console and both Error & Output in Log file - UNIX

I am writing a shell script with 2 run time arguments. During the execution if i got any error, then it needs to redirected to a error file and in console. Also both error and output to be redirected to a log file. But i am facing the below error. #! /bin/sh errExit () { errMsg=`cat... (1 Reply)
Discussion started by: sarathy_a35
1 Replies

10. Shell Programming and Scripting

Unable to grep using wildcard in a file.

I wish to check if my file has a line that does not start with '#' and has 1. Listen and 2. 443 echo "Listen 443" > test.out grep 'Listen *443' test.out | grep -v '#' Listen 443 The above worked fine but when the entry changes to the below the grep fails... (2 Replies)
Discussion started by: mohtashims
2 Replies
ftp(4)								   File Formats 							    ftp(4)

NAME
ftp - FTP client configuration file SYNOPSIS
/etc/default/ftp DESCRIPTION
Use the ftp file to configure the behavior of the FTP client. Lines that begin with a hash symbol ("# ") are treated as comment lines and are ignored. Behavior Directives The ftp file supports the following behavior directives: FTP_LS_SENDS_NLST=yes | no The ls command of the ftp client sends an NLST to the FTP Server by default. Several non-Solaris clients send LIST instead. In order to make the Solaris ftp client send LIST when the ls command is issued, set FTP_LS_SENDS_NLST to no. The value of FTP_LS_SENDS_NLST is yes by default. If the user sets a value for FTP_LS_SENDS_NLST in the user's environment, this value will override any FTP_LS_SENDS_NLST directive that is specified in /etc/default/ftp. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWbipr | +-----------------------------+-----------------------------+ SEE ALSO
ftp(1), attributes(5) SunOS 5.10 22 Oct 2002 ftp(4)
All times are GMT -4. The time now is 04:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy