Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script

Status
Not open for further replies.

kumariaru

IS-IT--Management
Mar 9, 2006
61
AU
Hi All,
Good Morning.. I have to ftp a file from one server to other server.And the platform is unix. I am totally new to shell scripting. From the help forums I have coded the script as follows:

#!/bin/ksh
HOST='bbm02'
USER='blter\intatch'
PASSWD='bb@c12'
Source='/eev/SS/wo7/stng'
Target='/Psoft'
File="abc.log"

open $HOST [29]
quote USER $USER
quote PASSWD $PASSWD
cd $Source
get $File
quit

But still I am not able to connect(Can login into bbm02 and can do ftp manually). Is anything I can do in this script with all your help.

Thank You.
 

You only missed the "ftp" command:
Code:
#!/bin/ksh
HOST='bbm02'
USER='blter\intatch'
PASSWD='bb@c12'
Source='/eev/SS/wo7/stng'
Target='/Psoft'
File="abc.log"
ftp <<EOF
open $HOST
quote USER $USER
quote PASSWD $PASSWD
cd $Source
get $File
quit
EOF
[3eyes]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Perhaps something like this ?
#!/bin/ksh
HOST='bbm02'
USER='blter\intatch'
PASSWD='bb@c12'
Source='/eev/SS/wo7/stng'
Target='/Psoft'
File="abc.log"
echo "\
open $HOST 29
quote USER $USER
quote PASSWD $PASSWD
cd $Source
lcd $Target
get $File
quit" | ftp -n -i

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You may have to replace this:
quote USER $USER
quote PASSWD $PASSWD
with this:
user $USER $PASSWD

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV and LKBrwmnDBA,
PHV, I have tried the script given by you. And I got the following error:



"good2.sh[14]: echoopen bbm02 29^Juser blter\intatch bb@c12^Jc
d /eev/SS/wo7/stng^Jlcd /Psoft^Jget abc.log^Jquit: not found"

And also I have tried the code in this way :
#!/bin/ksh
HOST='bbm02'
USER='blter\intatch'
PASSWD='bb@c12'
Source='/eev/SS/wo7/stng'
Target='/Psoft'
File="abc.log"
ftp<<EOF
open $HOST 29
user $USER $PASSWD
cd $Source
lcd $Target
get $File
quit

then I am getting the following error:
"Password:Name (bbm02:vkav):
User user blter\intatch bb@c12 cannot log in.
Login failed.
Please login with USER and PASS.
/Peoplesoft: No such file or directory
Please login with USER and PASS"""

These user id and the password are correct. But, while i am running the script it is asking for Password:

Thank You

 

OK, but the ftp is working!
Try this:
Code:
#!/bin/ksh
HOST='bbm02'
USER='blter\intatch'
PASSWD='bb@c12'
Source='/eev/SS/wo7/stng'
Target='/Psoft'
File="abc.log"
ftp -ni <<EOF
open $HOST 29
user $USER $PASSWD
cd $Source
get $File $Target
bye
EOF
[3eyes]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Hi LKBrwnDBA,
I have used the same script given by you. Right now I am getting following error:

$ ksh +x good3.sh
/eev/SS/wo7/stng: The system cannot find the path specified.
/Psoft: Permission denied

Thanks a lot
 
Hi,
Actually i want to ftp the file from /eev/SS/wo7/stng to /Psof. The above host,user and password are for the target.
 
lcd $Source
cd $Target

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV,
I have mentioned what you have given.
#!/bin/ksh
HOST='bbm02'
USER='blter\intatch'
PASSWD='bb@c12'
Source='/eev/SS/wo7/stng'
Target='/Psoft'
File="abc.log"
ftp -ni <<EOF
open $HOST 29
user $USER $PASSWD
lcd $Source
get $File
cd $Target
bye
EOF

but now i am getting this error.
"Local directory now /eev/SS/wo7/stng
abc.log: The system cannot find the file specified."

But there is a file in the source.I have checked it manually.

If this script is working fine , I will be really thankfull to all. I do not the unix scripting much.

Thanks



 
It's not really a unix scripting issue but a ftp one.
lcd $Source
cd $Target
put $File


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Your last attempt looked like a permission problem.

I always used the shell to automate FTP but recently switched to Expect.
Have you considered using that?


&quot;If you always do what you've always done, you will always be where you've always been.&quot;
 
Hi All,
Thanks a lot. I went with the script given by PHV. It is working fine and able to connect and ftp the file.

thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top