1

How can I pass a script to an sftp connection? e.g.

I make the sftp connection thus:

#sftpscript.sh
serverIP="1.2.3.4"  
sftp $serverIP

So far so good. Now I have a script the looks like this:

#sftpscript.sftp
lcd /path/to/newdir
cd /path/to/newdir
get filename.log.*
rm filename.log.*   

I tried:

sftp $serverIP:/path/to/sftpscript.sftp

but this just says it can't find sftpscript.sftp Is this possible? or am I going about this all wrong?

1 Answer 1

2

according to man page (e.g. sftp(1) ), syntax is

 sftp -b /path/to/sftpscript.sftp  $serverIP

however, I am not sure globbing option will work. (e.g. file.* )

2
  • 1
    SFTP has its own globbing expansion ways that considers the context (e.g. put blah* blah/ puts all local files starting with blah into the remote blah/ dir), and I think it should work just like we use the interactive SFTP. Commented Oct 26, 2015 at 13:14
  • that's worked perfectly, cheers for that.
    – IGGt
    Commented Oct 26, 2015 at 13:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .