From: Dave on
Gang,

I'm racking my brain over this and have searched and searched for
an answer with no luck. I'm trying to use the spawn command with
information passed in, but seem to fail no matter what I try. An
example:

$binary and $params are passed into the script and contain 'ls' and '-
al test.txt' respectively...
command: spawn -noecho $binary $params
produces: "-al test.txt: command not found"

how would I be able to provide parameters to a binary in the afore
mentioned fashion?

Thanks,
Dave
From: Arjen Markus on
On 2 jun, 00:07, Dave <hende...(a)gmail.com> wrote:
> Gang,
>
>      I'm racking my brain over this and have searched and searched for
> an answer with no luck.  I'm trying to use the spawn command with
> information passed in, but seem to fail no matter what I try.  An
> example:
>
> $binary and $params are passed into the script and contain 'ls' and '-
> al test.txt' respectively...
> command: spawn -noecho $binary $params
> produces: "-al test.txt: command not found"
>
> how would I be able to provide parameters to a binary in the afore
> mentioned fashion?
>
> Thanks,
> Dave

Try using the expansion operator {*} - or if you have Tcl 8.4 or
earlier [eval].

So:

spawn -noecho $binary {*}$params

or:

eval spawn -noecho $binary $params

(Though I am a bit surprised about the message - it seems to want to
run a command
"-al test.txt" ...)

Regards,

Arjen
From: Dave on
On Jun 2, 4:12 am, Arjen Markus <arjen.markus...(a)gmail.com> wrote:
> On 2 jun, 00:07, Dave <hende...(a)gmail.com> wrote:
>
>
>
> > Gang,
>
> >      I'm racking my brain over this and have searched and searched for
> > an answer with no luck.  I'm trying to use the spawn command with
> > information passed in, but seem to fail no matter what I try.  An
> > example:
>
> > $binary and $params are passed into the script and contain 'ls' and '-
> > al test.txt' respectively...
> > command: spawn -noecho $binary $params
> > produces: "-al test.txt: command not found"
>
> > how would I be able to provide parameters to a binary in the afore
> > mentioned fashion?
>
> > Thanks,
> > Dave
>
> Try using the expansion operator {*} - or if you have Tcl 8.4 or
> earlier [eval].
>
> So:
>
> spawn -noecho $binary {*}$params
>
> or:
>
> eval spawn -noecho $binary $params
>
> (Though I am a bit surprised about the message - it seems to want to
> run a command
> "-al test.txt" ...)
>
> Regards,
>
> Arjen


Thanks for the reply. I tried both answers with the first also
receiving an error, but the second seems to work without a problem.
Thanks again for your help!

Dave