Solved

spawn $command

Posted on 2009-05-16
1
2,323 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
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.

863 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

26 Experts available now in Live!

Get 1:1 Help Now