• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

DOS ">>" command to write to text file

rh71

No Lifer
*UPDATED - VBS help needed in my last post*

I am using psexec.exe (a command line utility that remotes to machines and outputs results to the local machine). What I am doing through a .vbs on (serverA) is kick off psexec on (serverB) an aspcommandush.exe command line exe on (serverC) which deletes machines on that serverC. FYI this is for Symantec Netbackup and serverC are the various backup servers. Ultimately, I want the delete performed, as well as logging the results to serverB... equally important.

All 3 components are required in this process since all VBS doing various things are on serverA and only serverB has the share where psexec.exe to remote and grab is, as well as where I want to store the results with the >> command. ServerC is where the delete-executable (aspcommandush.exe) and actual machines-to-delete are.

Technically I can remote to serverC (the backup servers) directly and run the aspcommandush.exe to delete machines but the point of all this is someone can delete any machine on any server by inputting the server name on the web and it's passed along thru the vbs.

The problem: The >> command to log to a text file is not working. It is performing the delete just fine but the resulting output is not logging. ServerC indeed has access to serverB to write this log file because when I remote to serverC directly and run the same delete command with >> at the end, it will perform the delete AND write the log file. But this has to be dynamic, run through the vbs.
 
>> is a function of the command processor which isn't what is running in the VBS file. I think the easiest solution is to prefix your command with "cmd /c". So you'd have
cmd /c something.exe >> test.txt
 
thanks for the lead... I tried cmd /c but nothing was showing up (except that the script completed) so I went with cmd /k to have the screen stay up so I can see any errors. Right now it's not even performing the delete, let alone creating / writing a log file.

In my vbs this is what I've simplified it to:
errReturn = shell.run ("\\serverB\apps$\netbackup\scripts\psexec \\serverC cmd /k d:\progra~1\verita~1\System\aspcommandush.exe -deletemachine machineA >> \\serverB\apps$\NetBackup\Scripts\logs\dailylog.txt", TRUE)

I run it that script on serverB via my laptop (not serverA because it's down for maintenance at the moment) using cscript and pointing to the location of that .vbs. It tries to psexec into serverC and then another DOS box blinks in and out, then it seems complete, but no delete or logging is done.

Do you see anything wrong with my code there? I take out the cmd /k and same exact result.
 
Maybe you need some more quotes. But you can only have one set in a command line. I don't think the cmd.exe is needed in this context, so I'd suggest:

errReturn = shell.run ("\\serverB\apps$\netbackup\scripts\psexec \\serverC ""d:\progra~1\verita~1\System\aspcommandush.exe -deletemachine machineA >> \\serverB\apps$\NetBackup\Scripts\logs\dailylog.txt""", TRUE)

I know nothing of psexec, by the way, but I think that's right in general.
 
No luck in the VBS with doubling up quotes.

What works:
===================================================
While on serverA, when I run this in a cmd prompt line, it works (do the delete & write the log file)

\\serverB\apps$\netbackup\scripts\psexec \\serverC d:\progra~1\verita~1\System\aspcommandush.exe -deletemachine machineA >> \\serverB\apps$\netbackup\scripts\logs\dailylog.txt

(note: with any quotes in the above, it won't work, so this is the correct statement I need, except in a VBS...)

===================================================


What doesn't work:
===================================================
When I run it through via VBS (kicked off on serverA), with extra quotes or not, it doesn't fully work (it does the delete, but not write the log file)

errReturn = shell.run ("\\serverB\apps$\netbackup\scripts\psexec \\serverC ""d:\progra~1\verita~1\System\aspcommandush.exe -deletemachine machineA"" >> \\serverB\apps$\NetBackup\Scripts\logs\dailylog.txt")

errReturn = shell.run ("\\serverB\apps$\netbackup\scripts\psexec \\serverC d:\progra~1\verita~1\System\aspcommandush.exe -deletemachine machineA >> \\serverB\apps$\NetBackup\Scripts\logs\dailylog.txt")

===================================================


Seems like I need a lesson in running commands in a VBS... how do I replicate the same command as the cmd prompt one?
 
Back
Top