Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


white spaces problem

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2638
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> white spaces problem
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 white spaces problem - 4/10/2005 10:05:11 PM   
  disktone

 

Posts: 9
Score: 0
Joined: 4/4/2005
From:
Status: offline
I am reading several lines from a text file, these are file paths to virtual servers that i need to get the status of.

i read the server.txt into an array then setting the variable cmdstr to = the dos command and line from the text file, however when i use the says file not found, this is because the file path has spaces

this is a example of one line from the servers.txt file

D:\Virtual Machines\BASE2000STD\win2000Serv.vmx

when i run my script i am using the Wscript.Echo to show me the variable cmdstr, which in this example wound be

cmd /c vmware-cmd D:\Virtual Machines\BASE2000STD\win2000Serv.vmx getstate >> status.txt

However it needs to have " " around the line i am reading from the text file, so the actual command would be presented like this

cmd /c vmware-cmd "D:\Virtual Machines\BASE2000STD\win2000Serv.vmx" getstate >> status.txt


Any ideas?? the only thing i can think of is to change the directory name, but that wound cause a lot of problems as there are 15 servers running in that dir






Set objTextFile = fso.OpenTextFile("c:\batch\server.txt", ForReading)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
vmwareserver = Split(strNextLine , vbCrLf)
For i = 0 to Ubound(vmwareserver)
cmdstr = "cmd /c vmware-cmd "+vmwareserver(i)+" getstate >> c:\batch\status.txt"

Wscript.Echo " command line: " & cmdstr

WshShell.run cmdstr
Next
Loop
 
 
Post #: 1
 
 Re: white spaces problem - 4/10/2005 10:32:31 PM   
  disktone

 

Posts: 9
Score: 0
Joined: 4/4/2005
From:
Status: offline
All sorted now

cmdstr = "cmd /c vmware-cmd """ & vmwareserver(i) &""" getstate >> c:\batch\status.txt"

(in reply to disktone)
 
 
Post #: 2
 
 Re: white spaces problem - 4/11/2005 5:16:40 AM   
  ralph

 

Posts: 11
Score: 0
Joined: 4/6/2005
From: Germany
Status: offline
uh... i wonder, why this works. i tried some usual escape sequences (like "executing \"cmd.exe /c dir\"" in a log file, tried """ also. after a while *g i read the documentation but i didn't find something useful.
since then i always use the chr(34) to 'escape' the double quotes.

(in reply to disktone)
 
 
Post #: 3
 
 Re: white spaces problem - 4/11/2005 5:46:46 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
using triple quotes does the same thing, its annoying, but it works.

(in reply to disktone)
 
 
Post #: 4
 
 Re: white spaces problem - 4/11/2005 6:18:56 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Technically speaking, there is no "escape" characters for a double-quote ("). The simple way to do it is to have ("") for every (") found.

(in reply to disktone)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> white spaces problem Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts