The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
#/usr/bin/csh -f not working as expected? effigy Shell Programming and Scripting 4 06-05-2006 06:00 PM
Var substitution in awk - not working as expected videsh77 Shell Programming and Scripting 3 01-13-2006 01:57 PM
ls not working as expected within ksh GNMIKE Shell Programming and Scripting 10 07-07-2005 08:53 AM
awk not working as expected with BIG files ... videsh77 Shell Programming and Scripting 1 02-24-2005 04:15 PM
which not working as expected osee Shell Programming and Scripting 2 09-07-2004 12:37 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-20-2009
RiSk RiSk is offline
Registered User
  
 

Join Date: May 2008
Posts: 20
TCL/Expect not working as expected

I am having an issue with TCL\Expect; I am passing arguments via the commandline that are read in via "lrange $argv". One of those var's is a password with characters that need to be escapaed, after escaping them an hitting enter expect is placing curly braces around my password... why?!


Code:
#!/usr/bin/expect

## Setting stdin arguments as vars

set user [lrange $argv 0 0]
set password [lrange $argv 1 1]
set bladen [lrange $argv 2 2]
set ilomuser [lrange $argv 3 3]
set ilompasswd [lrange $argv 4 4]
set frame [lrange $argv 5 5]

## Verify that all arguments have been fullfilled


puts "Am citit:\n";
puts "user: $ilomuser";
puts "password: $ilompasswd";

#check if all were provided

if { $user == "" || $password == "" || $bladen == "" || $ilomuser == "" || $ilompasswd == "" || $frame == "" }  {
   puts "Syntax error\r"
   puts "Usage: <Username> <Password> <Blade number in frame> <New ILOM User> <passwd for ILOM user> <Frame IP>\r"
      exit 1
 }


Example. I ctrl+c to kill.. but as you can see the password has been curly braced.

Code:

-(~/work/sun6kchassis/working)------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(14:40 Mon Jul 20)
risk@Heavyarms [161] --> ./setuprilo.exp root thisisapass 3 drrib \$bu\!d1t 1.4.132.123
Am citit:

user: drrib
password: {$bu!d1t}
^Czsh: exit 130   ./setuprilo.exp root thisisapass 3 drrib \$bu!d1t 1.4.132.123



---------- Post updated at 05:53 PM ---------- Previous update was at 02:58 PM ----------

tried it in bash, no avail, also tried quoting, nothing... running out of ideas.
  #2 (permalink)  
Old 07-21-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
The curly braces are special in TCL, the strings inside them are not interpolated. I suppose that's the correct behavior if you want the string to be passed as is.
  #3 (permalink)  
Old 07-21-2009
RiSk RiSk is offline
Registered User
  
 

Join Date: May 2008
Posts: 20
Well, the problem is, when it updates the password with that the password truely IS {$bu!d1t} when I need it to be $bu!d1t, any ideas?
  #4 (permalink)  
Old 07-21-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
Why aren't you using lindex?


Code:
set ilompasswd [lindex $argv 4]

Quote:
Note: ``lrange list first first'' does not always produce the same result as ``lindex list first'' (although it often does for simple fields that aren't enclosed in braces); it does, however, produce exactly the same results as ``list [lindex list first]''
  #5 (permalink)  
Old 07-21-2009
RiSk RiSk is offline
Registered User
  
 

Join Date: May 2008
Posts: 20
Quote:
Originally Posted by radoulov View Post
Why aren't you using lindex?


Code:
set ilompasswd [lindex $argv 4]

Because I know no better

But that fixed it !
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0