2013-07-18 73 views
0

我有一個簡單的腳本,我需要連接到SFTP並放置一個文件,下面是腳本。但我收到一條錯誤消息,顯示「沒有這樣的文件或目錄[email protected])」有人能幫我解決這個問題。提供密碼到SFTP

#!/bin/sh 
# sample automatic ftp script to dump a file 
USER="mgtest" 
PASSWORD="cald123" 
HOST="100.45.5.27" 
sftp -b [email protected]$HOST << EOF 
$PASSWORD 
#cd test_path 
put test_file.txt 
quit 
EOF 

執行畫面和錯誤

$ sh -x sftp_test.sh 
+ sh -x sftp_test.sh 
+ USER=mgtest 
+ PASSWORD=testpass 
+ HOST=100.45.5.27 
+ sftp -b [email protected] 
+ 0<< 
testpass 
#cd test_path 
#put test_file.txt 
quit 
No such file or directory ([email protected]). 

回答

0

參數-b需要一個批處理文件,而不是用戶名和密碼。請參閱docs for sftp

+0

感謝您的回覆,如何在腳本中提供密碼,我是sftp的新手。 – user2593788