From: Sooraj S on
Hi,

I am verynew to expect scripting. I want to pass a command from a perl
script to my expect script. Expect script should simpy execute that
command. But "cmd" in expect script is seen with a value "abc" instead
of the original value. Pls help me so

sample code :
-----------------------
my_perl.pl
---------------
.....
$command = "abc -option1 op1 -option2 op2"
system("./my_expect");
.....


my_expect
---------------
set cmd [lindex $argv 0]
puts "cmd"
From: Uwe Klein on
Sooraj S wrote:
> Hi,
>
> I am verynew to expect scripting. I want to pass a command from a perl
> script to my expect script. Expect script should simpy execute that
> command. But "cmd" in expect script is seen with a value "abc" instead
> of the original value. Pls help me so
>
> sample code :
> -----------------------
> my_perl.pl
> ---------------
> ....
> $command = "abc -option1 op1 -option2 op2"
> system("./my_expect");
> ....
>
>
> my_expect
> ---------------
> set cmd [lindex $argv 0]
> puts "cmd"

Looks like that mechanism in perl tokenizes $command
test with:

foreach arg $argv {
puts arg:$arg
}

if you want to spawn that command:
--tcl8.4: if 1 [ linsert $argv 0 spawn ]

tcl8.5++: spawn {*}$argv


uwe
From: Sooraj S on
Thanks for your reply.But I'm not tokenising the command. I want to
send the command as such from my perl script. Is it possible to accept
it in my expect script?

-----
$command = "abc -option1 op1 -option2 op2"
system("./my_expect $command");
----
From: Uwe Klein on
Sooraj S wrote:
> Thanks for your reply.But I'm not tokenising the command. I want to
> send the command as such from my perl script. Is it possible to accept
> it in my expect script?
>
> -----
> $command = "abc -option1 op1 -option2 op2"
> system("./my_expect $command");
> ----
no idea, I'm not a perlite ;-)

what about

system("./my_expect \"$command\"");

just a guess.

uwe
From: Sooraj S on
Thanks Klein....that worked :-)