Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-21-2012, 08:58 AM   #1
Registered: Mar 2009
Posts: 49

Rep: Reputation: 15
Expect scripting: argv contains file names and not my arguments

I'm having a problem trying to pass arguments through my expect script.

Here's my global variables:
# --------------------------------------------
# --------------------------------------------
set scriptName "UPS Event Log Archival Script"
set ver "v1.0"
set pass1 ""
set pass2 ""
set choice 0
set site ""
set logDir "upsEventLogs/[exec date +%Y-%m-%d]"
set failedLogDir "${logDir}/failed_downloads_[exec date +%Y-%m-%d].log"
set argSite [lindex $argv 0]
set argPass1 [lindex $argv 1]
set argPass2 [lindex $argv 2]
send_user -- "arg 0: [lindex $argv 0]\n"
send_user -- "arg 1: [lindex $argv 1]\n"
send_user -- "arg 2: [lindex $argv 2]\n"

send_user -- "argSite: $argSite\n"
send_user -- "argPass1: $argPass1\n"
send_user -- "argPass2: $argPass2\n"
My output:
[root@MON01 scripts]# expect -d ./upsArchival.exp * password1 password2
expect version 5.43.0
argv[0] = expect  argv[1] = -d  argv[2] = ./upsArchival.exp  argv[3] = 
dbTrnRecovery.exp  argv[4] = deployCommand.exp  argv[5] = deployFile.exp  
argv[6] = password1  argv[7] = password2
set argc 5
set argv0 "./upsArchival.exp"
set argv "dbTrnRecovery.exp deployCommand.exp deployFile.exp password1 
executing commands from command file ./upsArchival.exp
arg 0: dbTrnRecovery.exp
arg 1: deployCommand.exp
arg 2: deployFile.exp
argSite: dbTrnRecovery.exp
argPass1: deployCommand.exp
argPass2: deployFile.exp
So my question is why are the files the the directory being assigned as part of the argv list?

Last edited by edomingox; 03-21-2012 at 09:08 AM.
Old 03-21-2012, 09:11 AM   #2
Registered: Mar 2009
Posts: 49

Original Poster
Rep: Reputation: 15
Nevermind, I figured it out. It's because of the Star I'm using in:
[root@MON01 scripts]# expect -d ./upsArchival.exp * password1 password2
After using letters, it turns up fine.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on expect and arguments newbc Linux - Newbie 6 02-13-2012 09:17 PM
Bash scripting. Strip chars from file names, etc. mooreted Programming 7 02-11-2007 08:52 PM
Need some help in expect scripting anirudhasonar Programming 1 01-18-2007 12:11 PM
Expect scripting indienick Programming 2 09-22-2006 08:56 AM
expect scripting Deltron3030 Linux - Newbie 2 12-16-2003 01:56 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:56 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration