Solved

spawn $command

Posted on 2009-05-16
1
2,330 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

717 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