niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » shell
combine shell and expect script
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
Author Message
Jeremiah DeWitt Weiner
*nix forums Guru Wannabe


Joined: 08 Mar 2005
Posts: 140

PostPosted: Fri Feb 18, 2005 3:43 pm    Post subject: Re: combine shell and expect script Reply with quote

Thens <thens@nospamti.com> wrote:
Quote:
But, what I want to do is the script should automatically find the
location of expect and exec it with the expect interpreter.

Easy - make the shebang line like
#!/usr/bin/env expect
assuming that expect is somewhere in your PATH.

JDW
Back to top
Kenny McCormack
*nix forums Guru


Joined: 24 Mar 2005
Posts: 657

PostPosted: Fri Feb 18, 2005 12:59 pm    Post subject: Re: combine shell and expect script Reply with quote

In article <20050218183336.4b3377dd@asiclindt001>,
Thens <thens@NOSPAMti.com> wrote:
Quote:
Hello,

Iam writing an expect script to automate an interactive job. The script
could be run in both linux and solaris at my place and the location of
expect varies with the system.

I had

----- script ---------
#!/usr/local/bin/expect
expect script here

but this will not work on solaris, because the expect is at a different
location and ofcouse I could make it work by invoking it as

$ <path to expect> script

But, what I want to do is the script should automatically find the
location of expect and exec it with the expect interpreter.

#!/bin/sh
expect -- /dev/fd/5 {yourargs} 5<<- 'X'
{your expect program here}
X

Expect has a "-c" command line option that works like, e.g., "-e" in Perl,
that means "take the program directly from the cmd line instead of from
a file" but I've found it to be a little funky, so I avoid it.

The syntax above has worked flawlessly for me for several years.

</soapbox>
Note further that the #!/path/to/some/interpreter thingie is cute, but not
really that useful and should generally be avoided.
Back to top
Thens
*nix forums beginner


Joined: 21 Feb 2005
Posts: 3

PostPosted: Fri Feb 18, 2005 12:15 pm    Post subject: combine shell and expect script Reply with quote

Hello,

Iam writing an expect script to automate an interactive job. The script
could be run in both linux and solaris at my place and the location of
expect varies with the system.

I had

----- script ---------
#!/usr/local/bin/expect
< expect script here>

but this will not work on solaris, because the expect is at a different
location and ofcouse I could make it work by invoking it as

$ <path to expect> script

But, what I want to do is the script should automatically find the
location of expect and exec it with the expect interpreter. I have done this with perl and will need some help here.

Any pointers ?

Regards,
Thens.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 11:15 pm | All times are GMT
navigation Forum index » Programming » shell
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts does squid 2.6 support setting cache_peer port in redirec... Victor Tsang Squid 0 Fri Jul 21, 2006 8:16 am
No new posts mail script eeb4u@hotmail.com shell 3 Fri Jul 21, 2006 5:50 am
No new posts A simple bash script JPB Suse 2 Fri Jul 21, 2006 2:19 am
No new posts Getting started in PXPerl, i.e how to run a script? Markus Hänchen Perl 5 Thu Jul 20, 2006 2:12 pm
No new posts Match pattern in ksh script lnrntx@gmail.com shell 6 Thu Jul 20, 2006 1:48 am

Debt Consolidation | Loans | 0 Credit Cards | Mortgage | Personal Loans
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2065s ][ Queries: 20 (0.1354s) ][ GZIP on - Debug on ]