开发者

Transforming a sftp shell script command into a ftp command

开发者 https://www.devze.com 2023-04-02 16:02 出处:网络
I am writing my first shell script ever and trying to figure out how to transform this command: sftp -o IdentityFile=/home/test/test/id_dsa test@test.test.com < sftp_put.txt;

I am writing my first shell script ever and trying to figure out how to transform this command:

sftp -o IdentityFile=/home/test/test/id_dsa test@test.test.com < sftp_put.txt; 

into an equivalent command where I connect to a ftp server. The key difference is that I will be logging into this server via a username and password not my ssh credentials. Note I am trying to upload two files.

Again any help would be m开发者_Go百科ore than appreciated!


You can use .netrc for this:

$ cat > .netrc
machine your.machine.ip.address
login your.login.name
^D
$ ftp your.machine.ip.address < ftp_cmds.txt

Which would prompt you for a password. If you're okay with it, you can save the password (clear text) in .netrc to skip this prompt. See man netrc for more details.


   ftp -v -n <<EOF > ${LOG_FTP} 2>&1
   open ${IP_ADDRESS_SERVER}
   user ${FTPUSER} ${FTPPASS}
   cd ${REMOTE_DIR}
   put sftp_put.txt
EOF
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号