bje
asked on
ftp -i -n -v 2>$ftp_message_file 1>&2 <<EOF
I am trying to understand a ftp script. Does this mean that the output of 1 is being directed to 2 and does this mean that if no file is retrieve from the FTP session the script ends with status 16?
ftp -i -n -v 2>$ftp_message_file 1>&2 <<EOF
open $NODE
user $USER $PASS
cd $DIRECTORY
binary
get $FILE $FILE
del $FILE $FILE
bye
EOF
}
#
BASENAME=`basename $0`
if [ $# -ne 2 ]
then
echo "$BASENAME: usage $BASENAME <file_to_transfer> <directory>"
echo
echo "$BASENAME called with invalid number of parameters"
echo "Processing Abnormally Terminated"
exit 16
fi
Thanks for the assistance
ftp -i -n -v 2>$ftp_message_file 1>&2 <<EOF
open $NODE
user $USER $PASS
cd $DIRECTORY
binary
get $FILE $FILE
del $FILE $FILE
bye
EOF
}
#
BASENAME=`basename $0`
if [ $# -ne 2 ]
then
echo "$BASENAME: usage $BASENAME <file_to_transfer> <directory>"
echo
echo "$BASENAME called with invalid number of parameters"
echo "Processing Abnormally Terminated"
exit 16
fi
Thanks for the assistance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As per the given statements, I feel that the following statements comes at the end of a function inside a script:
bye
EOF
}
#
If the 2 parameters are not passed to the script it will display the following in the output:
ScriptName: usage ScriptName <file_to_transfer> <directory>
ScriptName called with invalid number of parameters
Processing Abnormally Terminated
Then the script is returning with the return code as "16".
The script will not return 16 if no file is present in the directory from the FTP session.
To get the error information from ftp function
Replace:
bye
EOF
}
#
With:
bye
EOF
grep -w "226" $ftp_message_file
if [ $? -eq 0 ]
then
echo "Successfull"
else
echo failure. Look into the file $ftp_message_file
fi
}
#
OR
With:
bye
EOF
grep -w "226" $ftp_message_file
if [ $? -eq 0 ]
then
echo "Successfull"
else
echo failure. Look into the file $ftp_message_file
exit anyNumberYouWish
fi
}
#
bye
EOF
}
#
If the 2 parameters are not passed to the script it will display the following in the output:
ScriptName: usage ScriptName <file_to_transfer> <directory>
ScriptName called with invalid number of parameters
Processing Abnormally Terminated
Then the script is returning with the return code as "16".
The script will not return 16 if no file is present in the directory from the FTP session.
To get the error information from ftp function
Replace:
bye
EOF
}
#
With:
bye
EOF
grep -w "226" $ftp_message_file
if [ $? -eq 0 ]
then
echo "Successfull"
else
echo failure. Look into the file $ftp_message_file
fi
}
#
OR
With:
bye
EOF
grep -w "226" $ftp_message_file
if [ $? -eq 0 ]
then
echo "Successfull"
else
echo failure. Look into the file $ftp_message_file
exit anyNumberYouWish
fi
}
#
In the given replacements
the following line:
grep -w "226" $ftp_message_file
can be replaced with:
grep -w "226" $ftp_message_file > /dev/null 2>/dev/null
the following line:
grep -w "226" $ftp_message_file
can be replaced with:
grep -w "226" $ftp_message_file > /dev/null 2>/dev/null
ASKER
So, the script will fail, if it does not pick up a file, correct? The parameters the script is looking for is the file it is picking up?
Thank you for your help.
Thank you for your help.
Hi,
The parameters the script is looking for are:
1) file_to_transfer
2) directory
If you don't specify both parameters, the script fill fail.
Regards,
-- mnh
The parameters the script is looking for are:
1) file_to_transfer
2) directory
If you don't specify both parameters, the script fill fail.
Regards,
-- mnh
ASKER
Thanks. This helps
bje
bje
The script checks if it was called with two arguments and if not it exits with error code 16.