Re: expect command spawns incorrectly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Sat, Nov 28, 2009 at 19:04, Steven W. Orr <steveo@xxxxxxxxxxx> wrote:
On 11/28/09 19:13, quoth Donald Russell:
>
>
> On Sat, Nov 28, 2009 at 15:47, Steven W. Orr <steveo@xxxxxxxxxxx
> <mailto:steveo@xxxxxxxxxxx>> wrote:
>
>     On 11/28/09 02:43, quoth Donald Russell:
>     > I am trying to use the expect program to automate an sftp process....
>     >
>     > The expect file begins with
>     >
>     > spawn sftp -oProxyCommand='....'  user@host
>     > expect "password:"
>     > send "sesame\n"
>     > expect "sftp> "
>
>     Try this:
>
>     send "sesame\r"
>
>
> I'll try that, but I'm not hopeful.
>
> The command that is spawned fails... I get the "usage" as if all that
> was spawned was "sftp" and not the entire command. So it doesn't even
> get to the "expect password" part, regardless of whether I'm using \n or
> \r in the "send".
>
> And I gather there is no such character on the "spawn" line... the
> command is just taken to be the literal characters up to the end-of-line.
> Do I need to escape anything? As I mentioned, if I cut/past the command
> into a shell.. it works fine... it's just got being spawned properly by
> expect. (Or I'm doing something wrong :-( )
>

Ok. One last suggestion. It sounds like you might have a quoting problem.


eval spawn "sftp -oProxyCommand='....'  user@host"

I'm assuming that you are using the single quotes to contain an argument that
may have possible embedded white space. In case there is no white space, it'll
probably also work without the single quotes. By default spawn will echo what
it's doing. You can stop that via the -noecho option.

Don't forget that expect is not a language of its own. It's just an extension
to the tcl language. tcl is what provides the eval. ;-)



Yes, I used single quotes because the -oProxyCommand= string contains spaces.
So, I removed the quotes, and escaped the spaces... works fine now.

Lessons learned: "spawn" doesn't handle quoted strings properly.

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.

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

Cheers
-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux