Requesting help with shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Requesting help with shell script
# 1  
Old 06-16-2011
Requesting help with shell script

I have been viewing man pages and using google with little luck so far. I am writing a shell script using wbemcli.

I can execute the command and get the results I need just fine.

ex. wbemcli -nl ein 'http://<username>:<password>@<host>/<targetpc>/root/wmi:MSAcpi_ThermalZoneTemperature'

from the command line, I will get back the instances available on the target pc like so.

<host>:5988/<targetpc>/root/wmi:MSAcpi_ThermalZoneTemperature.InstanceName="ACPI\\ThermalZone\\DTSZ_0"
<host>:5988/<targetpc>/root/wmi:MSAcpi_ThermalZoneTemperature.InstanceName="ACPI\\ThermalZone\\BATZ_0"
<host>:5988/<targetpc>/root/wmi:MSAcpi_ThermalZoneTemperature.InstanceName="ACPI\\ThermalZone\\CPUZ_0"
<host>:5988/<targetpc>/root/wmi:MSAcpi_ThermalZoneTemperature.InstanceName="ACPI\\ThermalZone\\LOCZ_0"
<host>:5988/<targetpc>/root/wmi:MSAcpi_ThermalZoneTemperature.InstanceName="ACPI\\ThermalZone\\VGAZ_0"

If an instance contains CPU, I want to grab the instance name, so I can execute the wbemcli command again to get specific property values.

The problem that I have is that the "http://..." string must be enclosed in single quotes. I have created variables in the script that will would replace the <username>, <password>, <host>, and <targetpc>, but from what I have read so far is that single quotes do no allow variable substitution.

I am not a complete noob to linux/unix, but I have never written something this complex previously. Any help would be greatly appreciated.

TIA,
Scott
# 2  
Old 06-16-2011
You can start and stop the quotes whenever you want without chopping up the resulting string. (Unless any of the variables contain spaces, in which case it will still get chopped up.)

Code:
echo 'This does not substitute'${BUT_THIS_DOES}'Back in single quotes'

You can also try double quotes, which do allow substitution, and won't ever chop up the string:
Code:
echo "Hello world, VAR1=${VAR1}"

If there's things in your URL which do funny things in double quotes, you can escape them with \ so they're interpreted literally.
Code:
echo "This is a literal dollar sign --> \$ <-- see?"


Last edited by Corona688; 06-16-2011 at 02:04 PM..
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 06-16-2011
I belive you have issues with escaping if i got it correctly.
Code:
VAR="\'http://whateverdotsite\'"
printf $VAR"\n"


Last edited by Peasant; 06-16-2011 at 01:14 PM.. Reason: Doh, didn't see an answer :)
# 4  
Old 06-16-2011
Thank you, Corona, by going and putting addition single qoutes around the variables, I was able to get it to work.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Requesting help for TL1 scripting

HI Everyone, I have TL1 script which takes the temperature of a CISCO equipment through TELNET now i need to save the output of the command to a csv file . Like this is the output > RTRV-SHELFSTAT:AB1S2a::1; AB1S2a 2016-02-03 22:29:39 M 1 COMPLD ... (2 Replies)
Discussion started by: adgjmpt
2 Replies

2. SCO

Requesting procedure to install SCO_UNIXWare7.1.4 on virtualbox

Sir I want to practice SCO_Unix so I want to install SCO_UnixWare7.1.4 on virtualbox so can you please suggest the procedure how to install it on virtualbox. My host Operating System is OpenSuse12.3. I am unable to run VmWare on my OS so please suggest how to install on virtualbox only. ... (0 Replies)
Discussion started by: rupeshforu3
0 Replies

3. Shell Programming and Scripting

Perl scripts: requesting for logic explanation

Hi, balajesuri and durden_tyler, I have found your perl script for the thread https://www.unix.com/shell-programming-scripting/176370-perl-script-help-me-extracting-string.html, but find it difficult to understand the syntax. Could you or any forum members kindly shed some light on the logic... (3 Replies)
Discussion started by: royalibrahim
3 Replies

4. Post Here to Contact Site Administrators and Moderators

Requesting a new forum

Hi admins and moderators!! Happy new year and merry Christmas :D Well, I have been here a few months now as a registered member and may be 6-7 years that I got numerous help directly and indirectly from this site as a guest. Unix.com really has a vast collection of posts on wide variety of... (15 Replies)
Discussion started by: admin_xor
15 Replies

5. Shell Programming and Scripting

Requesting help to replace a string by my bash script

Hello every1, I need help to replace a string in a file by my bash script. Find: log4j.appender.toLogFile.layout.ConversionPattern= %d %5p (%F:%L) - %m%n= %d %5p (%F:%L) - %m%n Replace: log4j.appender.toLogFile.layout.ConversionPattern= %d %5p (%F:%L) - %m%n I tried by sed, but kept... (7 Replies)
Discussion started by: titanic4u
7 Replies

6. Shell Programming and Scripting

requesting available port with shell script

how do I request a new and available local port (TCP) to use with shell script? (2 Replies)
Discussion started by: timmylita
2 Replies

7. Shell Programming and Scripting

Requesting full back up scripts

hi guys linux noob here wanting to learn linux scripting, i need help with a backup script that not only allows me to back up my files but restore them to my own personal directory, had a look at some of the coding from the scripts section on this site but still lost. any help is much appreciated (8 Replies)
Discussion started by: burnie35
8 Replies

8. Shell Programming and Scripting

Requesting input and for loop

Test - Test (1 Reply)
Discussion started by: Amit Sura
1 Replies
Login or Register to Ask a Question