LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-21-2012, 08:58 AM   #1
edomingox
Member
 
Registered: Mar 2009
Posts: 64

Rep: Reputation: 16
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:
Code:
# --------------------------------------------
#		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:
Code:
[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 
password2"
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
edomingox
Member
 
Registered: Mar 2009
Posts: 64

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


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:08 PM.

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