1

我有一个要求,我需要自动将特定文件从应用程序服务器中的一个位置传输到数据库服务器。

我可以使用这些步骤手动完成,但我需要在脚本中

#! /bin/ksh

directory path where the file need to be

ftp (hostname of the application server)

 username

 password

file location in the apps server

get filename

quit

任何帮助都非常感谢....

问候山姆

4

2 回答 2

0

你可以搜索一下:

ftp -inv <<EOF
   open app.server.address
   user username password
   cd some/location
   get filename
   bye
EOF
于 2013-09-20T13:31:03.060 回答
0

Expect是编写此类场景脚本的绝佳工具:

#!/usr/bin/expect -f 
spawn ftp ftp.ftpsite.com 
expect "ftp> " 
send -- "user MYUSER\r" 
expect "Password: " 
send -- "MYPASSWORD\r" 
expect "ftp> " 
send -- "cd /pub/test\r" 
expect "ftp> " 
send -- "put myfile\r" 
expect "File transfered" 
send -- "exit\r"
于 2013-09-20T14:09:08.513 回答