?
Solved

spawn $command

Posted on 2009-05-16
1
Medium Priority
?
2,336 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

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…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Suggested Courses

770 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