Operating System - HP-UX
1833568 Members
3558 Online
110061 Solutions
New Discussion

Scripting problem - quotes inside quotes

 
SOLVED
Go to solution
Ian Dennison_1
Honored Contributor

Scripting problem - quotes inside quotes

I am having real problems scripting a relatively simple OmniBack Command,...

I read the list of Objects from an OmniBack Backup, including the File System and the Description (which is enclosed in quotes), and then try to find the media for that File System.

The format of the command is

print $OBJ0 # File System spec
print $OBJ1 # Label
omnidb -session $SESSION -filesystem $OBJ0 $OBJ1 -media

This consistently comes up with 'Object not found', yet when I do a 'set -x' and drag and drop the resultant command into the shell, it works fine.

Things I have tried include,..
1. Running inside the script shell, rather than the backquote command
2. Removing the single quotes from the OBJ1 (Label) variable
(this works on the command line)
3. Putting backslashes before the quotes
4. Kicking the computer repeatedly.

Anyone else fancy a go?

Share and Enjoy! Ian

Building a dumber user
6 REPLIES 6
Martin Johnson
Honored Contributor

Re: Scripting problem - quotes inside quotes

Have you tried single and double quotes?

HTH
Marty
Sridhar Bhaskarla
Honored Contributor
Solution

Re: Scripting problem - quotes inside quotes

One kind of fancy way that I can think of is

echo "omnidb -session $SESSION -filesystem $OBJ0 $OBJ1 -media" >> /tmp/cmd$$

sh /tmp/cmd$$ > log_somewhere 2>&1

rm /tmp/cmd$$

See if it works??

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Ian Dennison_1
Honored Contributor

Re: Scripting problem - quotes inside quotes

Martin,

yep, tried single and double, backslash (one and two of), in just about every combination.

Sridhar,

Managed to try that just now. Thanks for the answer, it works but it feels like there is a more 'elegant' solution out there, that does not require spawning a new shell.

Thanks, Ian
Building a dumber user
Jonathan Baker
Advisor

Re: Scripting problem - quotes inside quotes

You could try eval omnidb -session $SESSION -filesystem $OBJ0 $OBJ1 -media
H.Merijn Brand (procura
Honored Contributor

Re: Scripting problem - quotes inside quotes

From a perl script you can use $ENV{BLAH} to access the environment variable $BLAH, and mix double quotes and single quotes like in the shell.

print "Env \$BLAH is $ENV{BLAH}\n";

but perl also has two `operators' for strings with quotes that would make things hard to parse/read otherwise: q// (single quotes) and qq// (double quotes). Equivalent to the shell's backticks (same in perl), it offers the qx// operator and the system () command

chomp (my $pwd = `pwd`);
print q{Today is }, qx{date};
print "Today is ", scalar localtime time;
print qq{Env "\$BLAH" is '$ENV{BLAH}'\n};

so ...

Given your example, I still don't know what you want exactly, but does not seem to be that much of a problem.
Enjoy, Have FUN! H.Merijn
Plank Guenther
Occasional Advisor

Re: Scripting problem - quotes inside quotes

Hi !

You don't need the quotes to query the db - so remove them:

OBJ1=$( echo $OBJ1 | sed "s/'//g")

hdh

Isnoquote