Solved

spawn $command

Posted on 2009-05-16
1
2,325 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
ID: 24404852
#!/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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

815 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

9 Experts available now in Live!

Get 1:1 Help Now