shell commands not working within SFTP script -
i novice in programming.. have sftp script sftp other server check conditions & file.
#! /usr/bin/bash while read line #echo $line if [[ $line =~ ^# ]]; #echo $line; continue; else serverip=`echo $line|cut -d',' -f1` userid=`echo $line|cut -d',' -f2` fi done < sftp.conf cd /root sshpass -p red32hat sftp $userid@$serverip <<eof (; ;) cd /root/perl #foreach $file (<$inputdir/*seq>) { $file in *seq abc1=`find $file -mmin +1`; if [[ $abc1 eq "" ]] echo "skipping file of file not completed \n"; continue; fi mget $file done sleep 30 done bye eof but throwing error @ every sftp step saying "invalid command".. guess general shell commands not working within sftp... please help...below error message...
eankuls@l9ahr43:~/idea_expan$ bash -x sftp_idea.sh + read line + [[ #bsackjsabckjdsbcds =~ ^# ]] + continue + read line + [[ rinacac-test,root =~ ^# ]] ++ echo rinacac-test,root ++ cut -d, -f1 + serverip=rinacac-test ++ echo rinacac-test,root ++ cut -d, -f2 + userid=root + read line + [[ #geet =~ ^# ]] + continue + read line + sshpass -p red32hat sftp root@rinacac-test ------------------------------------------------------------------------------------ these computer resources, internet access , e-mail, provided authorized users only. if not authorized user, please exit immediately. ------------------------------------------------------------------------------------ connected rinacac-test. sftp> ((;;)) invalid command. sftp> invalid command. sftp> cd /root/perl sftp> #foreach $file (<$inputdir/*seq>) { sftp> file in *seq invalid command. sftp> invalid command. sftp> abc1=`find $file -mmin +1`; invalid command. sftp> if [[ $abc1 == "" ]] invalid command. sftp> invalid command. sftp> echo "skipping file of file not completed \n"; invalid command. sftp> continue; invalid command. sftp> fi invalid command. sftp> mget $file couldn't stat remote file: no such file or directory file "/root/perl/$file" not found. sftp> done invalid command. sftp> sleep 30 invalid command. sftp> done invalid command. sftp> bye
add quote eof prevent expansions in here document:
sshpass -p red32hat sftp "$userid@$serverip" <<'eof' and place variables around quotes prevent word splitting , pathname expansion.
also for $file in *seq should for file in *seq.
for (; ;) should for ((;;)).
eq in [[ $abc1 eq "" ]] not valid operator. perhaps mean = or ==.
Comments
Post a Comment