View Full Version : [SLEEPER:] VBA-PERL via .bat
Hey guys,
I have a strange occurence when i'm running a .bat file from VBA (with shell)
I create a .bat file from vba and one of the lines calls a perl procedure with some variables.
The problem is this: when i run this batch file from inside vba it doesn't do what it should. When i run the same batch file directly it works!
I have no idea why or where to look for the error.
Thanx for the help
Kenneth Hobs
07-12-2012, 07:54 AM
We don't know what "doesn't do what it should" means. You will have to post code if you want to clarify what is going on or explain in more detail.
Sometimes, it is a matter of timing when you shell and need to wait for a process to complete. You may need a ShellWait() instead.
The perl is listing the items from a special access space, a sort of "show me what you have on that server"
the content of the file is:
set submit_Multisite=QY
PerlPath\myperl.pl ry ls | find "-" > MyPath\myfile.txt
that's it.
When i run the .bat directly i get a correct listing. When i run it with my macro myfile.txt remains empty.
Kenneth Hobs
07-12-2012, 08:22 AM
As I explained, try ShellWait(). Using that method, you may not even need to run the BAT file though you can if you like. http://www.vbaexpress.com/forum/showthread.php?t=34604
Hey Kenneth
Thank you for the help. Unfortunately, even with ShellandWait() it didn't work. It appears to be processing the command but the result file is empty.
I'll keep trying
By the way, i should have seen that it would not work - i wasn't fully running the macro yet - i'm still in the step into phase. So i'm taking it line by line and it doesn't populate the file.
Why writing to a file if you can get the result in a variable ?
sub snb()
c01=createobject("wscript.shell").exec("cmd /c PerlPath\myperl.pl ry ls | find -").stdout.readall
end sub
i'm writing to a file because i have to process the info afterwards (as in obtain a clean list of the files and add a command before each file name)
And i'm using a "set var=value" that shell errored out - file not found
I think I've located the problem! The server info i get from my perl needs a userid, because the info returned is different for each user.
The solution might be to use runas + sendkeys.. i'll keep digging
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.