passing passwd to a command in a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting passing passwd to a command in a script
# 1  
Old 07-03-2010
passing passwd to a command in a script

Hi All,

I have a requirment..
I need to pass a registry password to a command.. Actually when the command executed in the script, it will return some warnings first, then after it'll ask password like below,

Code:
 
$ cleartool rmtag -vob -all <vob_name>
Warnings: ------------------
Registry password:
$

I tried like below,
Code:
$ cleartool rmtag -vob -all <vob_name> <<eof
$pwd
eof

Here, 'pwd' variable is set with the registry password. But no luck.. it's still asking the passwd. I guess, it's because of that it's returning some warnings.. but i cant ignore those warnings...
Can anyone please provide the way to pass the passwd in this scenario?

Thank in advance..

Regards,
VRN
# 2  
Old 07-03-2010
Quote:
Originally Posted by raghu.iv85
...
Here, 'pwd' variable is set with the registry password. But no luck.. it's still asking the passwd. I guess, it's because of that it's returning some warnings.. but i cant ignore those warnings...
Can anyone please provide the way to pass the passwd in this scenario?
...
See if you could supply the password from a file.

Code:
$ 
$ # show the contents of the script "cleartool.sh"
$ cat -n cleartool.sh
     1    #!/bin/bash
     2    echo "Warnings: this is warning # 1"
     3    echo "Warnings: this is warning # 2"
     4    echo "Warnings: this is warning # 3"
     5    printf "Registry password: "
     6    read PSWD
     7    echo "Your registry password is $PSWD"
     8    ## And now the rest of the code...
$ 
$ # show the contents of the response file "myregistrypassword"
$ cat -n myregistrypassword
     1    PASSWORD_FROM_FILE
$ 
$ # run "cleartool.sh" and enter password from stdin
$ ./cleartool.sh rmtag -vob -all vobname
Warnings: this is warning # 1
Warnings: this is warning # 2
Warnings: this is warning # 3
Registry password: PASSWORD_FROM_STDIN
Your registry password is PASSWORD_FROM_STDIN
$ 
$ 
$ # run "cleartool.sh" and supply the password from the response file
$ ./cleartool.sh rmtag -vob -all vobname < myregistrypassword
Warnings: this is warning # 1
Warnings: this is warning # 2
Warnings: this is warning # 3
Registry password: Your registry password is PASSWORD_FROM_FILE
$ 
$

tyler_durden
# 3  
Old 07-03-2010
Hi tyler_durden,

Thank you for your reply..

I tried to pass the passwd from a file also... but no luck.. it's still asking the passwd.. I used the same way for passing the passwd when using `sudo su command`, it worked.. But it's not working for this command only,

And one more thing is we have stored the passwd in a hidden zip file, when we redirect the passwd as input to this command, it's unable to take the passwd..

Code:
$ cleartool rmtag -vob -all <vob_name> < .rgy_pwd.gz
Cleartool: Warnings: ---------------------------------
Registry passwd:  
## Here, it's asking passwd again even we provided it through file
$

I tried the same with normal file also (.rgy_pwd), it did not worked.. Smilie

Can you please advice on this..?

Thanks in advance..

Regards,
VRN..
# 4  
Old 07-03-2010
Quote:
Originally Posted by raghu.iv85
...
And one more thing is we have stored the passwd in a hidden zip file, when we redirect the passwd as input to this command, it's unable to take the passwd..

Code:
$ cleartool rmtag -vob -all <vob_name> < .rgy_pwd.gz
Cleartool: Warnings: ---------------------------------
Registry passwd:  
## Here, it's asking passwd again even we provided it through file
$

Of course it won't work in this manner, because you never supplied your correct password. What you did supply was a stream of bytes from that gzipped file. That's not your password.

Quote:
...
I tried the same with normal file also (.rgy_pwd), it did not worked..
Can you please advice on this..?
...
No idea about this. But I guess it doesn't hurt to ask - is your file ".rgy_pwd" an ASCII text file ? Or did you do a "mv .rgy_pwd.gz .rgy_pwd" ? That is, if you do a "cat .rgy_pwd" on your Terminal prompt, then you should be able to see your password as clear text.

If all the checks are done and if it still doesn't work, then I'd suggest you try the Expect language. See your man page for details and examples, or check the Expect website and FAQ.

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing command line parameters into script

Not a good post. (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

2. UNIX for Dummies Questions & Answers

Passing shell script parameter value to awk command in side the script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff |... (1 Reply)
Discussion started by: Sarita Behera
1 Replies

3. Shell Programming and Scripting

Passing the value of variable which is read from command line in called script

Hi, I am calling a Perl script in my shell script. When Perl script is executed it asks for a answer to be entered by user from terminal. How can i pass that value from my shell script ?? I know I can change perl script to default the answer but i dont have access to do that so only option i... (5 Replies)
Discussion started by: varun22486
5 Replies

4. Shell Programming and Scripting

Passing arguments from a bash shell script to a command

I'm pretty new to bash scripting and I've found myself writing things like this (and the same with even more nesting): if $CATEGORIES; then if $LABEL_SLOTS; then $pyth "$wd/texify_grammar.py" "$input" "$texfile" "--label-slots" "--categories" "$CATEGORY_LIST" ... (9 Replies)
Discussion started by: burbly
9 Replies

5. Shell Programming and Scripting

passing arguments to unix command or script inside tclsh

hi everobody kindly consider the following in tclsh I understand that we can do the following %exec UnixCmd arg1 arg2 but if I assinged the arguments to a list insde tclsh how can I use them back i.e %set ArgList %exec UnixCmd %exec Unixcmd $list %exec all the... (1 Reply)
Discussion started by: Blue_shadow
1 Replies

6. Shell Programming and Scripting

Passing value as a command line argument in awk script.

I have one working awk command line. Which taking data from the “J1202523.TXT” file and generating the “brazil.dat” file. PFB code. awk '{ DUNS = substr($0,0,9);if ( substr($0,14,3) == "089" ) print DUNS }' J1202523.TXT > Brazil.dat But now I want to pass two parameter as a command line argument... (4 Replies)
Discussion started by: humaemo
4 Replies

7. Shell Programming and Scripting

Issue in passing passwd to login into a sudo account

Hi Gurus, I have small issue... I used to pass the passwd for sudo commands like below, gzcat ~/passwd.gz | sudo su - <villin> >> eof ------ ----- ------ eof And it was able to login into "villin" sudo account successfully. But now, I'm using the same in another script for the... (2 Replies)
Discussion started by: raghu.iv85
2 Replies

8. Shell Programming and Scripting

passing database password to isql command in shell script

Hi, I need to connect to DB through my shell script. but I dont want to hardcode my db password in the script. Is there a way to do it? Thanks ---------- Post updated at 07:42 PM ---------- Previous update was at 04:54 PM ---------- :(Guys..please help me with this:( (1 Reply)
Discussion started by: agrawal.prachi
1 Replies

9. UNIX for Dummies Questions & Answers

Passing command output as an argument to a shell script

Hi, I have a very small requirement where i need to pass command output as an argument while invoking the shell script.. I need to call like this sh testscript.sh ' ls -t Appl*and*abc* | head -n 1' This will list one file name as ana argument.. I will be using "$1" in the shell... (2 Replies)
Discussion started by: pssandeep
2 Replies

10. Shell Programming and Scripting

Passing parameters to Shell script for GREP command

I am using grep to capture date from a file . Since i need to use the shell script for different dates ,is it possible to pass the date parameter to the shell script the Script is as below grep -E "08 Aug 2008|2008-08-08"* somefile.txt>test.txt The above script file greps the... (1 Reply)
Discussion started by: sud.tech
1 Replies
Login or Register to Ask a Question