Solved

spawn $command

Posted on 2009-05-16
1
2,321 Views
Last Modified: 2013-11-22
I have been trying all day, with no luck.  When I run this code, I always get an error.  What is the correct way to spawn a command from a string?  This should be so simple!  What is wrong with tcl?  I have been trying all day now.  I have tried doing it lots of different ways but with no luck.  Any help is GREATLY GREATLY appreciated.  I have also tried with #!/usr/bin/expect -f, but that didn't work either.

When I run this, I get the error below.  This is copy/pasted directly from my terminal.

$ ./test.exp
spawn ssh -p 22 localhost
Bad port ' 22 localhost'
#!/usr/bin/expect --
 

set command "-p 22 localhost"

spawn ssh [split $command]

interact

Open in new window

0
Comment
Question by:bryanatm
1 Comment
 
LVL 1

Accepted Solution

by:
bryanatm earned 0 total points
Comment Utility
#!/usr/bin/expect --

set command "ssh -p 22 localhost"
spawn {*}[split $command]
interact

I want to punch the inventor of tcl/expect in the face... how was I supposed to do this prior to tcl version 8.5?  I have no idea why this works and just doing a split doesn't work.  So frustrating.

http://wiki.tcl.tk/17158
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now