Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


enclose double quotes around a variable

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> enclose double quotes around a variable
  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 >>
 enclose double quotes around a variable - 11/21/2007 8:48:26 PM   
  avkuvalekar

 

Posts: 13
Score: 0
Joined: 11/8/2007
Status: offline
Hi,

I am having a strange kinda problem. I want to execute a dos command from vbscript which has a variable enclosed in quotes.

Lets say something like
cmd \c dir | find "abc.txt"
now this abc.txt is a variable that I am reading from somewhere else.
Now the problem is I don't seem to be able to do it. If I add """ around it then it takes the literals and there doesn't seem to be any way
of adding quotes around a variable and running it.

Please help me!
Thanks! :)
 
 
Post #: 1
 
 RE: enclose double quotes around a variable - 11/21/2007 8:58:29 PM   
  morpheus83uk

 

Posts: 379
Score: 0
Joined: 8/21/2006
Status: offline
Hello,

Try this function which I got from someone in here (Sorry I cant remember who it was!)


      

I am not entierly sure what your after but I think this might help you out.

Many Thanks

James

(in reply to avkuvalekar)
 
 
Post #: 2
 
 RE: enclose double quotes around a variable - 11/21/2007 9:07:38 PM   
  avkuvalekar

 

Posts: 13
Score: 0
Joined: 11/8/2007
Status: offline
Hi, thanks a lot for this one. Now this solves my problems to a great extent. The next doubt I have is whether and how can I take the output of this command in a variable in the script sothat I can compare the output and directly miplement my logic. What I am doing right now is writing this to a txt file and reading from there which is awfully slow! :(

(in reply to morpheus83uk)
 
 
Post #: 3
 
 RE: enclose double quotes around a variable - 11/21/2007 9:29:37 PM   
  morpheus83uk

 

Posts: 379
Score: 0
Joined: 8/21/2006
Status: offline
Hello,

If you can post your code for us then we can have a look at it for you.

Many Thanks

James

(in reply to avkuvalekar)
 
 
Post #: 4
 
 RE: enclose double quotes around a variable - 11/22/2007 1:14:38 PM   
  avkuvalekar

 

Posts: 13
Score: 0
Joined: 11/8/2007
Status: offline
Hi, the code is pretty simple so to say

I will tell you the entire requirements, as VBA and VBScript are quite nearby I am using this approach.
I have a spreadsheet that looks something like this -

quote:


s.no. name of the entitiy server run site
1        abcde                      ldnpsm123456


now, i run a command as
quote:

sfmontyd -s <server name> live list | find "name of the entity"


to this, if i get a blank row then i have to make it red otherwise green. Now, my first hurdle was to enclose the name of the entity in quotes, so I was writing the opt to the file
and scanning.
Now, that part is done so the next thing is I want to capture the output to a variable and take the first word of the output and compare it with the name entity, if it matches
then i make it green otherwise red.
As I have about 500 such rows for which this is to be checked, the file mechanism must be removed as it makes the program very slow.
I read something about exec method in vbscript. Does it exist in VBA too and how should I go about now?

Thanks!

(in reply to morpheus83uk)
 
 
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 >> enclose double quotes around a variable 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