Shell連到FTP問題 - Linux

By Vanessa
at 2011-10-18T05:16
at 2011-10-18T05:16
Table of Contents
※ 引述《qfacam (黑輪)》之銘言:
: 標題: [問題] Shell連到FTP問題
: 時間: Sun Oct 16 06:51:47 2011
:
: 請教一下各位高手們,
: 我寫了一隻shell去登入到ftp然後上傳
: 請參考一下原始檔,並看一下紅色的部份
: 主要是這兩行的關係問題,
: 我下了一個備份的指令,產生一個檔名為F502_今天的日期Ymd 例F502_20111016
: 然後連到ftp去上傳這個檔案,我試過用date同樣的寫法,但似乎在ftp上面不支援
: 請問在ftp上面有什麼寫法可以符合我的需求呢?
:
: #!/usr/bin/expect
:
: spawn ssh 10.0.252.2
: expect "Pass*"
: send "password"
: expect "*root*"
: send "b config save F502_`date +%Y%m%d`\n"
: send "cd /var/local/ucs/\n"
: send "ftp 10.0.115.100\n"
: expect "*Name*"
: send "itnoc\n"
: expect "*word*"
: send "Welcome1\n"
: expect "ftp>"
: send "put F502_20111016.ucs\n"
: send "exit\n"
: send "exit\n"
: expect eof
分享一下,我的寫法
第一隻shell,從別台server ssh到LB去做備份
#!/usr/bin/expect
spawn ssh 10.0.252.13
expect "Pass*"
send "password can't share@@"
expect "*root*"
send "b config save LB22_`date +%Y%m%d`\n"
send "cd /var/local/ucs/\n"
send "sh ./ftp.sh\n"
expect eof
第二隻shell
這隻是放在LB上面
#!/bin/bash
user="user"
pw="password can't share@@"
ftp="10.0.115.100"
lbname=$(date +'%Y%m%d')
cd /var/local/ucs
ftp -in <<EOF
open $ftp
user $user $pw
bin
put LB22_$lbname.ucs
close
bye
EOF
:
: --
: 標題: [問題] Shell連到FTP問題
: 時間: Sun Oct 16 06:51:47 2011
:
: 請教一下各位高手們,
: 我寫了一隻shell去登入到ftp然後上傳
: 請參考一下原始檔,並看一下紅色的部份
: 主要是這兩行的關係問題,
: 我下了一個備份的指令,產生一個檔名為F502_今天的日期Ymd 例F502_20111016
: 然後連到ftp去上傳這個檔案,我試過用date同樣的寫法,但似乎在ftp上面不支援
: 請問在ftp上面有什麼寫法可以符合我的需求呢?
:
: #!/usr/bin/expect
:
: spawn ssh 10.0.252.2
: expect "Pass*"
: send "password"
: expect "*root*"
: send "b config save F502_`date +%Y%m%d`\n"
: send "cd /var/local/ucs/\n"
: send "ftp 10.0.115.100\n"
: expect "*Name*"
: send "itnoc\n"
: expect "*word*"
: send "Welcome1\n"
: expect "ftp>"
: send "put F502_20111016.ucs\n"
: send "exit\n"
: send "exit\n"
: expect eof
分享一下,我的寫法
第一隻shell,從別台server ssh到LB去做備份
#!/usr/bin/expect
spawn ssh 10.0.252.13
expect "Pass*"
send "password can't share@@"
expect "*root*"
send "b config save LB22_`date +%Y%m%d`\n"
send "cd /var/local/ucs/\n"
send "sh ./ftp.sh\n"
expect eof
第二隻shell
這隻是放在LB上面
#!/bin/bash
user="user"
pw="password can't share@@"
ftp="10.0.115.100"
lbname=$(date +'%Y%m%d')
cd /var/local/ucs
ftp -in <<EOF
open $ftp
user $user $pw
bin
put LB22_$lbname.ucs
close
bye
EOF
:
: --
Tags:
Linux
All Comments
Related Posts
ibus 輸入框消失 & ppa.launchpad.net 404 not found

By Ula
at 2011-10-18T01:35
at 2011-10-18T01:35
更改path

By Thomas
at 2011-10-17T23:07
at 2011-10-17T23:07
更改path

By Oscar
at 2011-10-17T22:36
at 2011-10-17T22:36
Ubuntu的更新問題

By Elvira
at 2011-10-17T21:33
at 2011-10-17T21:33
Ubuntu的更新問題

By Erin
at 2011-10-17T15:03
at 2011-10-17T15:03