$Variable with 's within "s


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting $Variable with 's within "s
# 1  
Old 07-19-2013
$Variable with 's within "s

I am trying to get a variable to work within a script, but it is giving me issues.

Goes like:

echo "var"
I enter: '12345'
read var

echo "$var"
It returns: '12345'
I am trying to get it to run in a script which has usage of script.sh "'12345'" (I cannot modify this script)

script.sh "$var"
script doesn't work because it shows as 12345 without quotes
I have tried multiple ways to try and get it to work with adding ', `, parenth etc, but can't figure it out

Any tips?
# 2  
Old 07-19-2013
Hi,

Try this out

Code:
VAR=12345
echo "\"$VAR\""

o/p:- "12345"

i have tried it successfully....

Last edited by Scott; 07-19-2013 at 05:14 PM.. Reason: Code tags, please
# 3  
Old 07-19-2013
@OP: What does the script look like?
# 4  
Old 07-19-2013
dont have my other machine with me, but the script takes a bunch of #'s that are VARCHAR so they have to be comma separated(if you're doing more than one) and in single quotes.

I know what you mean though, Ill post up the parameters within the script to show what it will accept when I get back to my other machine.

@vinit: i need the original variable to have single quotes because of the SQL's executed earlier within my script.

now im thinking i could maybe modify the SQL's to already have the single quotes so my variable doesn't need them.

Thanks all for the ideas so far Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Infinite "while" loop subshell loses current date variable

I have a simple script to log network connectivity to a set of systems. However, as expected the date appended to the log never changes because the new variable is lost when the loop starts again. Can someone clue me in on how to get around this issue? #!/bin/bash LOG=/tmp/netlog... (3 Replies)
Discussion started by: woodson2
3 Replies

2. Shell Programming and Scripting

Unable to store "python --version" to a shell variable

Hi All, I need to get the version of python installed and store it in a variable for later use. Whereas it is printing on the console instead of storing to variable. I am able to store output of ls command in a variable. Please check the below code : root@myhost:/volumes/srini# cat... (4 Replies)
Discussion started by: srinivasan.neel
4 Replies

3. Solaris

Netra X1 LOM: Unable to change any variable via the "set" command

I'm posting here as it didn't seem quite right in the hardware section (as it's LOM commands). My apologies if I have that wrong though :) I've finally gotten round to configuring the LOM on my Netra X1, but I can't get it to change the hostname via the "set" command: lom>show hostname... (2 Replies)
Discussion started by: Smiling Dragon
2 Replies

4. Shell Programming and Scripting

if [ "variable" = "numerical-range" ]; then

been a while so i'm a bit rusty and need a little help. writing a script that needs to compare $EXECHOST(a number) against a numerical range and then set a value. below isn't working but should give you folks an idea of my goal: if ; then echo "This is a 32B machine, exiting..." if ;... (4 Replies)
Discussion started by: crimso
4 Replies

5. Shell Programming and Scripting

sed - extract string before "/" from variable- linux 2.6.9-89

Hi, I have a FTP script which gets called from a wrapper script that exports a variable having value as: "/export/home/dips/logs/dipsSFTP_file1.log.YYYYMMDDHHMISS". I want to extract the file name "dipsSFTP_file1.log.YYYYMMDDHHMISS" and the dir path "/export/home/dips/logs/" from this... (4 Replies)
Discussion started by: dips_ag
4 Replies

6. Shell Programming and Scripting

passing the output of cmd from "eval" to a variable

Hello, I need help with the eval command. I have been building a lengthy cmd using eval, and I need to create $var from the output of the cmd. Here is what I have. Out=/dfezz1/output.txt Node="'LPAR Info:'" Gr3p0=" |grep" Printc=" prtconf" Output1=" 1>>$Out 0>&1" Cat1="cat... (8 Replies)
Discussion started by: dfezz1
8 Replies

7. Shell Programming and Scripting

defining a variable using multiple "entries/columns" within a line using read

Hello All, I am trying to figure out how to use the read command. I have a txt file that has rows looking something like this: 1 2 3 4 5 6 7 8 9 where each number represents an entry of various characters deliminated by tabs. My goal is to set entries 2-7 as a variable/string that I... (3 Replies)
Discussion started by: Torinator
3 Replies

8. Programming

getting "mi_cmd_var_create: unable to create variable object" error msg

Hi, i am working in C in Fedora Eclipse 3.3.0 with gdb debugger. I am geting segmentation fault with an error message "mi_cmd_var_create: unable to create variable object" on debugging the program. What should I do to solve this problem? rgds, Dona_m (14 Replies)
Discussion started by: dona_m
14 Replies

9. Shell Programming and Scripting

Sed , Replace a "variable text" inside of a statement

Please Help... I am trying to manipulte the following line Before : <user:Account_Password>002786</user:Account_Password> the password is the "variable", i need to delete / omit the password in the file, (it occurs several thousand times) so the tag line looks like After:... (4 Replies)
Discussion started by: jackn7
4 Replies

10. Shell Programming and Scripting

Please help formatting bash "time" variable to HH:MM:SS format

Ok, this is going to be hard to describe, but here it goes. I have written a bash script that, while executing starts a timer, and when done stops the timer. The $RUNTIME variable value is in seconds, so the variable usually equals a number like 126 (equals 2 minutes 6 seconds). In my script I... (3 Replies)
Discussion started by: vikingshelmut
3 Replies
Login or Register to Ask a Question