- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Pass a parameter that contains a dollar sign
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 09:20 AM
06-01-2006 09:20 AM
First script calls the second script:
The second script echos the parameter received:
+ newpass=/c
Obviously not correct.
I also have this example:
<script name> $TAs5SRJ.tlhQ
+ newpass=.tlhQ
Is the leading dollar sign causing this behavior? If so, do I change the calling script or the called script (and how)?
TIA,
Scott
Solved! Go to Solution.
- Tags:
- makekey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 09:25 AM
06-01-2006 09:25 AM
Re: Pass a parameter that contains a dollar sign
<script name> "\$TAs5SRJ.tlhQ"
will fix you as the \ is escaping the special meaning of $.
- Tags:
- quoting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 09:28 AM
06-01-2006 09:28 AM
Re: Pass a parameter that contains a dollar sign
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 09:34 AM
06-01-2006 09:34 AM
Re: Pass a parameter that contains a dollar sign
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 09:40 AM
06-01-2006 09:40 AM
Re: Pass a parameter that contains a dollar sign
For example, if I had:
$hj7f$k38$$l
could I run it through some command to get:
\$hj7f\$k38\$\$l
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 10:40 AM
06-01-2006 10:40 AM
Re: Pass a parameter that contains a dollar sign
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 11:05 AM
06-01-2006 11:05 AM
SolutionRather than capturing makekey's stdout in a variable directly do something like this:
PLAINTEXT="12345678.k"
PWHASH=$(echo "${PLAINTEXT}" | /usr/lbin/makekey | awk '{gsub("$","\$"); print $0}')
echo "PWHASH = \"${PWHASH}\""
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 01:38 PM
06-01-2006 01:38 PM
Re: Pass a parameter that contains a dollar sign
You asked:
/* begin quote */
For example, if I had:
$hj7f$k38$$l
could I run it through some command to get:
\$hj7f\$k38\$\$l
/* end quote */
...Yes, here's a simple way:
# echo '$hj7f$k38$$l'|perl -ne 'print quotemeta'
\$hj7f\$k38\$\$l\
# X=`echo '$hj7f$k38$$l'|perl -ne 'print quotemeta'`; echo ${X}
\$hj7f\$k38\$\$l\
Note that we use single quote marks around the string to prevent the shell from interpreting the dollar-signs.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2006 01:54 AM
06-02-2006 01:54 AM
Re: Pass a parameter that contains a dollar sign
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2006 02:16 AM
06-02-2006 02:16 AM
Re: Pass a parameter that contains a dollar sign
One small correction - the addition of the '-l' switch so the snippets read:
# echo '$hj7f$k38$$l'|perl -nle 'print quotemeta'
\$hj7f\$k38\$\$l
(and):
# X=`echo '$hj7f$k38$$l'|perl -nle 'print quotemeta'`; echo ${X}
\$hj7f\$k38\$\$l
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2006 06:54 AM
06-02-2006 06:54 AM
Re: Pass a parameter that contains a dollar sign
echo "12345.k" | /usr/lbin/makekey | sed s/\\$/\\\\$/g
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2006 03:09 AM
07-14-2006 03:09 AM
Re: Pass a parameter that contains a dollar sign
solution is vastly simpler than all of the
other suggestions.
When the first script calls the second,
it need only place the encrypted string in
single quotes. This will prevent any attempt
to interpret the argument as a shell variable.
tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2006 05:21 AM
07-14-2006 05:21 AM
Re: Pass a parameter that contains a dollar sign
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2006 08:13 AM
07-14-2006 08:13 AM
Re: Pass a parameter that contains a dollar sign
the whole problem is that this is not a constant; that would be easy. Instead it's a variable that may happen to include the "$" metacharacter
Yes, I also thought it was as simple as Tim said.
Here are my two scripts:
$ more dollar_parm
#!/usr/bin/ksh
ABC=$(echo '$def/sam') # generate key
echo $ABC
dollar_parm2 "$ABC" # quotes not needed
$ more dollar_parm2
#!/usr/bin/ksh
echo $1
Both scripts echo: $def/sam
It seems that once you get a $ in a parm, it will stay there. So you should be able to capture the output of makekey and pass that.
- Tags:
- variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2006 08:57 AM
07-14-2006 08:57 AM
Re: Pass a parameter that contains a dollar sign
I too, think the issue is somewhat easier than Clay avers.
create encrypted password using makekey, assigning same to a variable name. Call subsequent script with this variable as an arguement.
An interactive example:
#!/bin/sh
read password
my_key=`echo ${password}|/usr/lbin/makekey`
;# now call subsequent script with my_key
next_script ${my_key}
next_script then can act on $1 (or whichever arguement was passed)
If you desire to reassign $1 to some other more logically named variable, that is done normally
newpass=$1
when using newpass, just enclose with brackets as was done with my_key in the first script.