<br><br><div class="gmail_quote">On Sat, Nov 28, 2009 at 19:04, Steven W. Orr <span dir="ltr"><<a href="mailto:steveo@syslang.net">steveo@syslang.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

On 11/28/09 19:13, quoth Donald Russell:<br>
<div class="im">><br>
><br>
> On Sat, Nov 28, 2009 at 15:47, Steven W. Orr <<a href="mailto:steveo@syslang.net">steveo@syslang.net</a><br>
</div><div><div></div><div class="h5">> <mailto:<a href="mailto:steveo@syslang.net">steveo@syslang.net</a>>> wrote:<br>
><br>
>     On 11/28/09 02:43, quoth Donald Russell:<br>
>     > I am trying to use the expect program to automate an sftp process....<br>
>     ><br>
>     > The expect file begins with<br>
>     ><br>
>     > spawn sftp -oProxyCommand='....'  user@host<br>
>     > expect "password:"<br>
>     > send "sesame\n"<br>
>     > expect "sftp> "<br>
><br>
>     Try this:<br>
><br>
>     send "sesame\r"<br>
><br>
><br>
> I'll try that, but I'm not hopeful.<br>
><br>
> The command that is spawned fails... I get the "usage" as if all that<br>
> was spawned was "sftp" and not the entire command. So it doesn't even<br>
> get to the "expect password" part, regardless of whether I'm using \n or<br>
> \r in the "send".<br>
><br>
> And I gather there is no such character on the "spawn" line... the<br>
> command is just taken to be the literal characters up to the end-of-line.<br>
> Do I need to escape anything? As I mentioned, if I cut/past the command<br>
> into a shell.. it works fine... it's just got being spawned properly by<br>
> expect. (Or I'm doing something wrong :-( )<br>
><br>
<br>
</div></div>Ok. One last suggestion. It sounds like you might have a quoting problem.<br>
<br>
<br>
eval spawn "sftp -oProxyCommand='....'  user@host"<br>
<br>
I'm assuming that you are using the single quotes to contain an argument that<br>
may have possible embedded white space. In case there is no white space, it'll<br>
probably also work without the single quotes. By default spawn will echo what<br>
it's doing. You can stop that via the -noecho option.<br>
<br>
Don't forget that expect is not a language of its own. It's just an extension<br>
to the tcl language. tcl is what provides the eval. ;-)<br>
<div><div></div><br></div></blockquote></div><br><br>Yes, I used single quotes because the -oProxyCommand= string contains spaces.<br>So, I removed the quotes, and escaped the spaces... works fine now.<br><br>Lessons learned: "spawn" doesn't handle quoted strings properly.<br>

<br>Oddly enough, when spawn was echoing the command with the signle quotes and spaces, the echoed command was correct... I could cut/paste it into a shell unmodified and it worked. So, yes, there's something in the way spawn actually spawns the command.<br>

<br>Anyway, it's working now and I can move forward. :-)<br><br>Cheers<br>