Having trouble using expect to launch vpn program | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Having trouble using expect to launch vpn program

Shell Programming and Scripting


Tags
expect script, linux

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-21-2013
wblakenc wblakenc is offline
Registered User
 
Join Date: Jun 2013
Last Activity: 24 June 2013, 10:25 AM EDT
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Question Having trouble using expect to launch vpn program

Hello all.

I am a linux and linux scripting newbie so please forgive my ignorance. I have been tasked to write what I thought should be a pretty simple script that does the following:
1) Loads our forticlient ssl vpn command line client
2) sends the vpn password to the client

Pretty simple. However I am having trouble getting following code to work:


Code:
#!/usr/bin/expect -d
set pw "test"
eval spawn ./forticlientsslvpn_cli --server vpnserver --vpnuser theuser
expect "Password for VPN:"
send "$pw\r"

A couple of things, yes I know that having the password as clear text not a good idea. I am just trying to get this to work.

Second, I know that the -d in the first line provides debugging info. I am not sure if this is the cause of my trouble, however when I use -f when the script is run, I still see the prompt for the password and the program pauses like it is waiting for my input. At least with -d I can see a little bit of what is going on, and it looks like it should work.

Suggestions? I am lost and a bit over my head.
Sponsored Links
    #2  
Old 06-21-2013
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 21 November 2014, 7:36 PM EST
Location: Southern NJ, USA (Nord)
Posts: 4,522
Thanks: 8
Thanked 555 Times in 532 Posts
I write most of my expect using a trial run under 'autoexpect'. Then I do not need to know expect or tcl.
The Following User Says Thank You to DGPickett For This Useful Post:
wblakenc (06-24-2013)
Sponsored Links
    #3  
Old 06-24-2013
wblakenc wblakenc is offline
Registered User
 
Join Date: Jun 2013
Last Activity: 24 June 2013, 10:25 AM EDT
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Thank you

Autoexpect works nicely, plus it wrote a working script for me to take a look at and figure out what I was doing wrong. I think the main problem was timing. There were a few commands I was missing as well.

Thank you!

Will
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell Script to launch C program gazmcc182 Shell Programming and Scripting 12 04-11-2010 05:04 PM
Problem with external program launch Zipi Programming 7 02-21-2009 01:30 PM
BASH: how to launch a program with parameters TinCanFury Shell Programming and Scripting 5 03-15-2008 04:02 AM
launch an executable from a C++ program nadiamihu Programming 2 11-03-2006 05:59 AM
how to launch program though telnet cbachman UNIX for Dummies Questions & Answers 3 03-21-2005 04:31 PM



All times are GMT -4. The time now is 09:47 AM.