Dollar symbol in Shell Script Variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Dollar symbol in Shell Script Variable
# 8  
Old 09-21-2017
What we want to say is that --passphrase "abc$123" does NOT work as intended because it expands to --passphrase "abc${1}23" and if $1 is empty expands to --passphrase "abc23".
But
Code:
passphrase='abc$123'
... --passphrase "$passphrase"

works correctly. Maybe it does not work because your actual passphrase is abc23 ?
# 9  
Old 09-21-2017
Quote:
Originally Posted by Sreehari
Hi,

I am maintaining all keys in a file say ABC.pwdf

Contents of ABC.pwdf
================
Code:
<bank> <recipient> <signer> <passphrase>
WFB 0X12343 0x1234 abc$123

================

Reading these keys in shell script
=================
Code:
lnCount=0;
while read pString
do
	lvbank=`echo  ${pString}|cut -d ' ' -f1`

	if [ "$lvbank" = "$l_bank" ]``
	then		
		lnCount=`expr $lnCount + 1`
		recipient=`echo  ${pString} | cut -d ' ' -f2`;
		signer=`echo  ${pString} | cut -d ' ' -f3`;
		passphrase=`echo  ${pString} | cut -d ' ' -f4`;		
	fi;
done < ${PwdFileName};

======================
I am getting all values correctly. Having problem only when I am using passphrase in PGP command

Thanks,
Sreehari
For the third time, that is not all of your code. Now the bit with PGP in it is missing.

Post all your code.
# 10  
Old 09-21-2017
Thanks RudiC, I got the difference between harcoded value and variable. We decided to change passphrase without dollar sign.
# 11  
Old 09-25-2017
If your code - whatever it is - is evaluating dollar signs in passwords, that's a big problem. What if someone set their password to $(rm -Rf /var/importantdata) ?

Please show your code so we can find out why it's doing that.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How can I assign awk's variable to shell script's variable?

I have the following script, and I want to assign the output ($10 and $5) from awk to N and L: grdinfo data.grd | awk '{print $10,$5}'| read N L output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
Discussion started by: geomarine
8 Replies

2. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell 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 | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

3. Shell Programming and Scripting

$ symbol in sql query in shell script

Hi Team, Can you please help me to resolve this issue. Am unable to use this $ symbol in sql query in the shell script. For Example: # !/bin/sh export USER_NAME=XXX export PASSWORD=YYY export ORACLE_SID=xamdb echo $ORACLE_SID echo " Session Details ..." ... (1 Reply)
Discussion started by: indira_s
1 Replies

4. Shell Programming and Scripting

[Solved] cp command with dollar variable in ksh

hi, I have been trying to acheive the following task for a while now, but failed.. Need help, experts please help! This is what I am trying to do: - I am writing to a flat file the name of the source to be copied and the destination path as to where it is to be copied to. Sample flat file:... (7 Replies)
Discussion started by: abdulhusein
7 Replies

5. Shell Programming and Scripting

how to remove the target of the symbol link in a shell script

I have a target directory, there are some files and directories in "target_dir". I have a symbol link: my_link -> <target_dir> The target directory name is NOT known to the script (because it is varying), while the link name is always fixed. In a shell script, how to remove both the... (1 Reply)
Discussion started by: princelinux
1 Replies

6. Shell Programming and Scripting

assign awk's variable to shell script's variable?

Dear All, we have a command output which looks like : Total 200 queues in 30000 Kbytes and we're going to get "200" and "30000" for further process. currently, i'm using : numA=echo $OUTPUT | awk '{print $2}' numB=echo $OUTPUT | awk '{print $5}' my question is : can I use just one... (4 Replies)
Discussion started by: tiger2000
4 Replies

7. Shell Programming and Scripting

Expect Script square bracket dollar prompt

Hi Thanks for this amazing forum first, I've been searching answers in it for problems that I've encountered at work. The only problem I haven't been able to find a fix for, is a ever waiting for prompt problem in Expect when encounter a $ prompt. I usually set the timeout to -1 cause the... (2 Replies)
Discussion started by: Ikaro0
2 Replies

8. Shell Programming and Scripting

How to type the Omega symbol Ω in unix shell script

Hi, I have a data file delimited by Ω symbol, I would like to use this in grep and cut command. but How to type this Omega symbol. Thanks Murugesan (1 Reply)
Discussion started by: NagaMurugesan
1 Replies

9. Shell Programming and Scripting

direction symbol in a variable as part of the command

Hi, How can I get this to work? #!/bin/ksh if ; then direction=">>" else direction=">" fi cat some_file_name $direction temp.txt exit This shell script is not happy with using "$direction" opposed to ">" or ">>". Thanks. (5 Replies)
Discussion started by: peterloo
5 Replies

10. Shell Programming and Scripting

Registered Symbol in Korn Shell script

When I am trying to write this symbol in shell script ( ® ) I am getting a . ( dot ) instead , does anybody know how to fix it. Thanks. (1 Reply)
Discussion started by: jacki
1 Replies
Login or Register to Ask a Question