1828490 Members
2554 Online
109978 Solutions
New Discussion

Re: Expect scripting

 
SOLVED
Go to solution
Patrick Wallek
Honored Contributor

Expect scripting

I am trying to do some scripting with expect and I cannot figure out how to do what I need to do.

The problem is that I have a script that runs every day, but part of the input is the previous days date.

So what I need to do with expect is something like:

VAR1=$(caljd.sh -o $(caljd.sh -p 1))
send -- "${VAR1}\r"

How can I set a variable within expect to a value calculated by executing a shell command? I have searched high and low and I cannot figure out how to do that.

Thanks in advance!!!
3 REPLIES 3
Peter Godron
Honored Contributor

Re: Expect scripting

Patrick,
would it be possible to use a temp file to read from??
Regards
Steven E. Protter
Exalted Contributor
Solution

Re: Expect scripting

You use caljd.sh same way I do. Thanks for the concept validation.

Could you write this variable output to a file?

Then have the expect script source the file the same way users source .profile ... Just an out of the box concept.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Patrick Wallek
Honored Contributor

Re: Expect scripting

Thanks for the ideas guys. I did what you suggested.

I wrote a shell script that will generate the file with the dates I need, and the correct syntax for expect.

I then call my expect script from that shell script and source the file I created with the values I need.

This is much more elegant that what I was originally doing.