AIX FTP client

I am trying to transfer logs from Aix 6.1 to a linux appliance but it is not happening from last one month if i execute the batch command by command i can execute well but if i do it in shell script it is stuck without any error.

Any one know how to generate a FTP client trace to know the issue with FTP batch file.

---------- Post updated 03-02-14 at 11:53 AM ---------- Previous update was 03-01-14 at 01:30 PM ----------

bump.....

Whilst it's naughty to bump up your posting, we will be unable to answer until you explain what your problem is a bit more.

Can you tell us:-

  • Was this working before?
  • What changed?
  • Is this FTP or SFTP?
  • Can you publish your script in CODE tags for us to consider? Sanitise any credentials.
  • What output do you get manually and from a scheduled job?
  • How is the job scheduled?
  • Can you see it try at the expected time?
  • Are there any errors recorded on the server side?
  • Is the account active with a valid password?
  • Has the password expired?

Regards,
Robin

Sorry not my intention to play tricks but i am really need of suggestion since this issue has taken my sleep and peach of mind away.

Please find below my answers to your query.

This is a fresh script.
We are able to send the logs manually by keying the same commands in the script
This is FTP
pls find the script at the end.
manually i am able to use mput command and at destination is see logs transferred but schedule sends the logs once and freezes then.

job is scheduled through cronjob every 10 minutes and the log file size is around 20 mb.
the script freezes at execution without any error
I do not know how to check error on a linux box since the server is a RHEL appliance
Credentials are not the problem here.
Password is fine and works when keyed in manually.

Shell script below :------

/usr/bin/cd /usr
echo "**************************************************************" >> /usr/Mac.log
/usr/bin/date >> /usr/Mac.log
/usr/bin/cp -p /usr/stream.out /logs/AIX1.`/usr/bin/date +%H%M%d%m%Y`
/usr/bin/ftp -n -i "ipaddress" <<EOF
user ftpuser password
lcd /usr
cd Aix
prompt
mput AIX*
quit
EOF
mv /usr/AIX* /usr/archived/
echo "finish" >> /usr/Mac.log

Thank you inadvance

Try replacing this:

/usr/bin/ftp -n -i "ipaddress" <<EOF

With this

/usr/bin/ftp -n -i "ipaddress" >> /usr/Mac.log 2>&1 <<EOF

Your log may supply more info then

I am getting the below error message on the terminal

cp: 0653-437 /logs/AIX1./usr/bin/date +%H%M%d%m%Y is not a directory.

in the cp step i am copying all files with /usr/stream.out* with present date and time to /logs/AIX1.`/usr/bin/date +%H%M%d%m%Y`

this line is giving the issue any suggestion would be much appreciated.

So, this is before the start of the FTP call. Perhaps you should resolve that first.

You might be best defining your output file name first and then issuing the copy.

Robin

Hi Rbatte,

Could you give an example.I do not know how to do that.

Something like this

file_name="/logs/AIX1."$( date +%H%M%d%m%Y )
cp -p /usr/stream.out $file_name

Make sure you have all the directories like /log and the file you are trying to copy.
Also make sure the path of the commands are correct.

If it still doesn't work, past the output of your script with -x i.e. bash -x your_script

--ahamed

A few suggestions...

If this is a shell script it should be in an executable file with a line at the shebang at the top. Like this:

#! /usr/bin/ksh
echo I am a script
exit 0

I have the uncomfortable feeling that you are trying to put all of this code directly in your crontab file. That is not a great idea. Also I can look at the shebang line and instantly see that I am dealing with a ksh script. We have to guess about what shell you are using.

Don't run an external cd program. This the most useless thing that Posix has done. "/usr/bin/cd /usr" will not change the script's current directory. You must use the shell's built-in cd command for that.

You might want to consider switching to YYYYMMDDHHMM as you name your log files. They will sort in chronological order that way.

ra8ul,

So a few things, now that I've looked a second time.

You don't need the /usr/bin/cd /usr line at all. You give the full paths everywhere else in your script.

Did you replace the ftp command with the suggestion from Chubbler_XL What output do you now get in the log file?

Perhaps you have typed your quotes correctly here, but they might be incorrect in your script. On the line to copy the file, you have a pair of back-quotes ` so it should run the data command. I've pasted your command onto my AIX server and it runs fine. Perhaps in your script you have used normal single quotes '

Try duplicating the line and displaying it before executing, i.e.:-

echo "**************************************************************" >> /usr/Mac.log
/usr/bin/date >> /usr/Mac.log

echo /usr/bin/cp -p /usr/stream.out /logs/AIX1.`/usr/bin/date +%H%M%d%m%Y` >> /usr/Mac.log 2>&1
/usr/bin/cp -p /usr/stream.out /logs/AIX1.`/usr/bin/date +%H%M%d%m%Y` >> /usr/Mac.log 2>&1

/usr/bin/ftp -n -i "ipaddress" >> /usr/Mac.log 2>&1 <<EOF
user ftpuser password
lcd /usr
cd Aix
prompt
mput AIX*
quit
EOF

mv /usr/AIX* /usr/archived/
echo "finish" >> /usr/Mac.log

I've spaced it out to make it a little easier to read. Can you try running with that and tell us what you see. I can see two things that seem a bit odd, but rather than leap in and tell you, it would be better for you to have a go yourself.

Good luck. Let us know how you get on. Do ask for help if you see messages that you don't understand.

Robin

Thanks to Chubber,Robin,ahmed,Perderabo for the help.

This my first Aix system i was also not sure how it was working without the first shell extension #! /usr/bin/ksh .

Coming to the error actually i was putting stream.out* in my script thats the reason the script was not working.After removing multiple files from the source dir and/or removing the * the error went away.And the script was successful.

Thank you to all and apologies for not posting the updated code.