Log file is not getting created & unable to grep error from it
Hi All,
Below is my code,what I am trying to do is redirecting output of ftp to a log file & then greping the errors but here I am unable to grep "Permission denied" error only & also the corresponding log file is also not getting created.
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:
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.
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:
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.
Thanks methyl, for your comments.
I incorporated them & now the log file is getting created.
Now I am not checking the ftp exit status instead just putting everything in one log file & greping the errors from it & putting in another log file.
Need one more suggestion from you, once the files are ftp'ed i want them to move to filename.done in the same directory from where I am reading the files but this should only happen when there are no errors in ftp i.e. the file has actually ftp'ed then only it should be renamed to .done.
1) You could ftp the file under a temporary name and rename the target file with a ftp "rename" at the end of the process. Then use a ftp "dir" command to show that the file exists. Then rename the source file.
2) Check that your error file exists but is empty.
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)