Passing "$1$" as an argument


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing "$1$" as an argument
# 1  
Old 12-03-2012
Passing "$1$" as an argument

Hi

I have a strange issue and hence asking for your help.

I am using a RHEL machine and the user passwords are stored inside /etc/shadow file. These are md5 encrypted passwords. I am extracting these encrypted passwords in a shell script and want to pass them to another shell script. But these passwords look like - "$1$98meo/YZ$.qOaoqb", or "$5$5gHl7rC19jx0UHTm50" - they start with $[1-9]$. Hence I am not able to transfer them correctly. Initial $1$ is getting converted into "ignoreeof". For example

Code:
script_name $1$98meo/YZ$.qOaoqb
script_name "$1$98meo/YZ$.qOaoqb"

nothing works.

In the same context
Code:
[ferrari-int] a=$1$567
[ferrari-int] echo $a
ignoreeof67

Is there any way to transfer the value to another script as an argument? I know if we escape the $, then it will work -
Code:
[ferrari-int] a=\$1\$567
[ferrari-int] echo $a
$1$567

But is it the only way?

If this escaping is the only way, then how we can replace the initial $1$ by \$1\$? What should be the sed liner?

Thanks in advance.
# 2  
Old 12-03-2012
Try:

Code:
a='$1$567'

And you're echo-ing wrongly Smilie

Code:
echo "$a"

or better:

Code:
printf '%s\n' "$a"

Just to add, it should be:

Code:
script_name '$1$98meo/YZ$.qOaoqb'


Last edited by radoulov; 12-03-2012 at 01:25 PM..
This User Gave Thanks to radoulov For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Python : Problem with " TypeError: float() argument must be a string or a number "

Hello ! I'm creating a CGI which allow to display graph from some data. The datas looks like : 2020-01-13-00-00,384.00,350.00 2020-01-13-06-00,384.00,350.00 2020-01-13-12-00,384.00,350.00 2020-01-13-18-00,384.00,350.00 2020-01-14-00-00,384.00,350.00... (1 Reply)
Discussion started by: Tim2424
1 Replies

2. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

3. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

4. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

"Again passing argument to awk" !!

hi, I have this script #!/usr/bin/awk -v var1=1 -f $17==31 END{ { print $0 } } exit i am passing a file name from the command line now i want to make the 17th field value to be passed from command line. How can i do that, (1 Reply)
Discussion started by: aryasoumen
1 Replies

7. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

8. Programming

error "Invalid argument" returned after call sched_setscheduler

the code is below and the was run on Solaris 9. ----------------------------- struct sched_param param; param.sched_priority = 99; if(sched_setscheduler(0, SCHED_RR, &param) == -1) { perror("setting priority"); exit(1); } ------------------------------- after the... (1 Reply)
Discussion started by: robin.zhu
1 Replies

9. Shell Programming and Scripting

Passing argument to "at" command

Is it possible to pass an argument from the command line to the "at" command? I want "at" to run a script which requires a few arguments from the command line when it runs. Example: at 10:00 -f myscript.sh param1 param2 Unfortunately "at" sees everything on the line as command options to... (2 Replies)
Discussion started by: nibl
2 Replies
Login or Register to Ask a Question