Re: passing a variable to an expect script
- From: Bryan Oakley <oakley@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 30 Jun 2006 19:12:42 GMT
scriptnewbe wrote:
I have a ksh script that does some calculations on the dates and then
passed 3 dates to an expect script.
Ksh script variable:
/dir1/dir2/Scripts/achcust $yd1 $yd2 $yd3
Then in my expect script, I have
set yd1 "[lrange $argv 0 0]"
set yd2 "[lrange $argv 1 1]"
set yd3 "[lrange $argv 2 2]"
Later in the script when I am trying to use the set string ....., I try
to call the variable $yd1 $yd2 and $yd3.
The expect script is not recognizing the variables. The odd thing is
that when I run a ps -ef |grep on the script while it is running, it
has the correct values being passed to the expect script.
Help me please!
The short answer is: you're doing something wrong, but without seeing your code it is impossible to know what mistake you've made.
If I had to guess (and I guess I do...) I'd say that either you're doing the "set yd1 ..." in a proc and haven't declared argv as global, or the place where you're using yd1, etc doesn't declare those variables as global.
Do either of those sound like the problem?
Also, [lrange $argv 0 0] is incorrect and could yield bad results. You should use [lindex $argv 0]. lrange returns a list, lindex does not.
Most of the time it won't matter, but if any of the arguments have special characters you'll discover that [lrange $argv 0 0] is not precisely the same as [lindex $argv 0] (and the latter will return the proper value).
--
Bryan Oakley
http://www.tclscripting.com
.
- References:
- passing a variable to an expect script
- From: scriptnewbe
- passing a variable to an expect script
- Prev by Date: Re: passing a variable to an expect script
- Next by Date: LAST CHANCE!: Call For Papers: 13th Annual Tcl/Tk Conference, Oct. 9-13, 2006
- Previous by thread: Re: passing a variable to an expect script
- Next by thread: LAST CHANCE!: Call For Papers: 13th Annual Tcl/Tk Conference, Oct. 9-13, 2006
- Index(es):
Relevant Pages
|
|