LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Automatic ftp using cron problem (https://www.linuxquestions.org/questions/linux-general-1/automatic-ftp-using-cron-problem-437536/)

giteshtrivedi 04-21-2006 04:09 PM

Automatic ftp using cron problem
 
Hello friends,

I got problem using cron. I have created a shell script which is
automatically ftp my files to remote server.But when manually I
executed same shell script it works fine.When I configure same script
in cron it is not working and gave me errors.

My Shell script is as follows...
ftp -i -n 192.168.10.4 <<EOF
user oracle Shekjg34
cd /u05/oralog/starship
bin
mput *.ARC
bye
EOF
exit 0

I also changed coding of above script as follows...

RHOST1=SolidOra12
USER1="oracle"
PASSWD1="Shekjg34"

ftp -n -i $RHOST1 <<EOF >>/oracle/admin/starship/adhoc/new_ftp/ftp_d.txt
user "$USER1" "$PASSWD1"
cd /u05/oralog/starship
bin
mput *.ARC
bye
EOF
exit 0

But each time it gave me following errors..

Login incorrect.
Login failed.
Please login with USER and PASS.
Please login with USER and PASS.

Please let me guide to resolve this issue.
Thanks in Advance.

Regards,
Gitesh

bathory 04-21-2006 04:23 PM

You can try ftp://oracle:Shekjg34@192.168.10.4 to see if it works (some ftp clients work with this URL)
Or use a .netrc in the user that runs the cronjob home directory with the following:
Code:

machine 192.168.10.4
login oracle
password Shekjg34

and in your script use just "ftp 192.168.10.4<<EOF ..."

giteshtrivedi 04-21-2006 05:10 PM

Hi friend,

Thanks for replying.

I cann't find .netrc file in oracle user home.Second thing I want to put more then 1 file also also due to I put ftp -i for noninterective mode.Your said ftp:// can you tell me how can I put -i there?

Please give me guidence.I am so much confused.

Thanks a lot in Advance.

Gitesh

bathory 04-22-2006 09:26 AM

You have to create the .netrc file since it doesn't exist. And you can use "prompt off" inside your script:
Code:

#!/bin/sh
ftp 192.168.10.4 <<EOF
cd /u05/oralog/starship
bin
prompt off
mput *.ARC
bye
EOF

The other method is not sure that it works with all ftp clients (I've tested it and it works with Suse but not with Slackware). Just replace "ftp 192.168.10.4" with "ftp ftp://oracle:Shekjg34@192.168.10.4" in the above script to see if it works.

giteshtrivedi 04-22-2006 11:26 AM

Thanks
 
Hello frinds,

Thanks very much for your valuable help.I have created .netrc in user's $HOME directory and give 600 permission.Now my said script is works fine with cron.

Once again thanks a million to you.

Regards,
Gitesh Trivedi


All times are GMT -5. The time now is 07:55 PM.