Page 1 of 1
Double Quotes!
Posted: Sat Jul 06, 2013 6:30 am
by stoavio
Hi all,
I'm throwing in the towel on this one. After over an hour of trying different combinations to get this to work, I simply cannot figure it out.
I am trying to execute this command using get shell and put it in a variable. The command is:
Code: Select all
ipconfig /all | find "Host Name"&ipconfig /all | find "IP Address"&ipconfig /all | find "Subnet Mask"&ipconfig /all | find "DNS Servers"
As you can see, this is already concatenated and is done this way so I can store the output from everything in one variable.
The double quotes are throwing me. I understand this is what the quote constant is for but I can't seem to figure out the proper syntax for executing this command. I have had a variety of errors but the latest one is:
Code: Select all
'"Host Name"' is not recognized as an internal or external command,
operable program or batch file.
Can someone help? I've already lost 90 minutes of my life to something I'm sure is ridiculously simple. I just need to see it once!

Re: Double Quotes!
Posted: Sat Jul 06, 2013 6:57 am
by wsamples
It often helps to post the entire code, in your case including the shell("<command to run>") in order to make sure the advice you receive addresses your issue.
Can you simply replace the double quotes in your command with single quotes? This typically works and LiveCode is not confused because the single quotes have no meaning to it, thus you can wrap the command with the required "..." and quote as necessary within the command using single quotes.
Re: Double Quotes!
Posted: Sat Jul 06, 2013 7:05 am
by wsamples
In using the quote constant you need to be certain to add the " in the right places as you build the sting and confusion is very common in the beginning.
Example:
"this is a quoted "string" containing a quoted section"
becomes:
"this is a quoted" && quote & string & quote && "containing a quoted section"
The & concatenates two strings while && concatenates with an added space. Notice that we must fully quote the two sections of the original string which flank the section being quoted with constants.
Re: Double Quotes!
Posted: Sat Jul 06, 2013 7:20 am
by stoavio
Hi wsamples.
I am happy to post the code. I did try using just the single quotes inside of "..." and the command prompt does not interpret the command correctly. In the following code I have attempted to use single quotes just so you can see what I was trying to accomplish.
Code: Select all
on menuPick pItemName
hide group "Validate Settings"
switch pItemName
case "Validate Settings"
Global ipconfig
show group "Validate Settings"
set the hideconsolewindows to true
get shell("ipconfig /all | find 'Host Name'&ipconfig /all | find 'IP Address'&ipconfig /all | find 'Subnet Mask'&ipconfig /all | find 'DNS Servers'")
put it into ipconfig
set the itemDel to ":"
//check host name
if "ALOHABOH" is in ipconfig then
put "ALOHABOH" into fld "Computer Name"
set foregroundColor of fld "Computer Name" to "#2c9303"
else
put item 1 of ipconfig into fld "Computer Name"
set foregroundColor of fld "Computer Name" to "#e72b00"
set textStyle of fld "Computer Name" to "bold"
end if
//check IP address
if "192.168.1.100" is in ipconfig then
put "192.168.1.100" into fld "IP Address"
set foregroundColor of fld "IP Address" to "#2c9303"
else
put item 13 of ipconfig into fld "IP Address"
set foregroundColor of fld "IP Address" to "#e72b00"
set textStyle of fld "IP Address" to "bold"
end if
//check subnet mask
if "255.255.255.0" is in ipconfig then
put "PASS" into fld "Subnet Mask"
set foregroundColor of fld "Subnet Mask" to "#2c9303"
else
put "FAIL" into fld "Subnet Mask"
set foregroundColor of fld "Subnet Mask" to "#e72b00"
set textStyle of fld "Subnet Mask" to "bold"
end if
//check primary DNS
if "208.67.222.222" is in ipconfig then
put "PASS" into fld "Primary DNS"
set foregroundColor of fld "Primary DNS" to "#2c9303"
else
put "FAIL" into fld "Primary DNS"
set foregroundColor of fld "Primary DNS" to "#e72b00"
set textStyle of fld "Primary DNS" to "bold"
end if
//check secondary DNS
if "208.67.220.200" is in ipconfig then
put "PASS" into fld "Secondary DNS"
set foregroundColor of fld "Secondary DNS" to "#2c9303"
else
put "FAIL" into fld "Secondary DNS"
set foregroundColor of fld "Secondary DNS" to "#e72b00"
set textStyle of fld "Secondary DNS" to "bold"
end if
break
case "Restore Data"
hide group "Validate Settings"
break
end switch
end menuPick
Although Livecode isn't reporting any errors, the return from the command line is attached. Unfortunately the single quote method doesn't appear to work in this situation.
Re: Double Quotes!
Posted: Sat Jul 06, 2013 7:22 am
by dave_probertGA6e24
try either:
Code: Select all
"ipconfig /all | find 'Host Name'&ipconfig /all | find 'IP Address'&ipconfig /all | find 'Subnet Mask'&ipconfig /all | find 'DNS Servers' "
or
Code: Select all
"ipconfig /all | find " "e& "Host Name" "e& "&ipconfig /all | find " "e& "IP Address" "e& "&ipconfig /all | find " "e& "Subnet Mask" "e& "&ipconfig /all | find " "e& "DNS Servers" & quote
or
Code: Select all
"ipconfig /all | find \"Host Name\"&ipconfig /all | find \"IP Address\"&ipconfig /all | find \"Subnet Mask\"&ipconfig /all | find \"DNS Servers\" "
see if they work.
Cheers,
Dave
Re: Double Quotes!
Posted: Sat Jul 06, 2013 7:36 am
by stoavio
dave_probertGA6e24 wrote:try either:
Code: Select all
"ipconfig /all | find 'Host Name'&ipconfig /all | find 'IP Address'&ipconfig /all | find 'Subnet Mask'&ipconfig /all | find 'DNS Servers' "
or
Code: Select all
"ipconfig /all | find " "e& "Host Name" "e& "&ipconfig /all | find " "e& "IP Address" "e& "&ipconfig /all | find " "e& "Subnet Mask" "e& "&ipconfig /all | find " "e& "DNS Servers" & quote
or
Code: Select all
"ipconfig /all | find \"Host Name\"&ipconfig /all | find \"IP Address\"&ipconfig /all | find \"Subnet Mask\"&ipconfig /all | find \"DNS Servers\" "
see if they work.
Cheers,
Dave
Dave, the second one worked! Thanks man.
I appreciate you guys helping me out. I was hoping to get your option 3 to work since it is considerably less code. I will keep playing with it but at least now it is working.
Thanks again!
