In expect it is possible to spawn a process like,
spawn /usr/bin/sftp "$uri" /home/user/dest
Writing it like this makes things really simple, it will be a one liner. However, I am trying to replicate this for upload. This is a bit more complicated,
spawn /usr/bin/sftp "$uri" <<< $'put "$source"'
Most likely the issue is that this is bash code and not a single command. Is there a way to spawn something like this in expect, or will I have to do it the long way? I also tried with braces, to no success.
BR Patrik
Expect.pm
module (and the various protocol-specific modules likeNet::SSH
,Net::Telnet
, andNet::SFTP
, etc) to be a lot more useful and easier to work with thanexpect
itself. Amongst other benefits, there's no need for messing around with shell quoting or escaping, just use perl vars where they're needed. Python has similar capabilities with, e.g., thepexpect
library. – cas Sep 05 '19 at 00:50expect
, especially when you'll use it only rarely. IMO that time is better spent learning or improving your skill with a general purpose language like perl or python, which you'll use far more often for many and varied tasks. – cas Sep 05 '19 at 00:53