File.execute() is not executing my script. How to debug this issue? - adobe-illustrator

I'm writing a script for Illustrator CS6 in ExtendScript. At the end of my script, I want to spawn a task (a second script, in Ruby) using File.execute(). However, it's not working. And I'm at a loss as how to debug the problem -- how can I figure out why this isn't working?
Here's the end of my ExtendScript file:
// Do a bunch of other work, then:
var rubyFile = new File(scriptFolder + 'BuildHtmlWalkthrough.rb');
alert(rubyFile.exists);
var result = rubyFile.execute();
alert(result);
Both rubyFile.exists and result are always true, indicating that the script launched OK. But the script does not appear to run, at all. I've tried the following diagnostics:
The Ruby script does successfully run from the command line. The script's permissions are -rwxr-xr-x
I added a call to system("touch /blah/blah/blah") as the very first line of the Ruby script. The file does not get touched.
I thought maybe the ExtendScript process was terminating before the Ruby script could run, so I added a long for loop after rubyFile.execute(). Spinning for > 30 seconds did not help.
What can I do to debug, or solve, this problem?
I'm on MacOS X v10.9.1. And for reference, this is the documentation for File.execute():
File.execute (): Boolean
Core JavaScript Classes
Executes or opens
this file using the appropriate application, as if it had been
double-clicked in a file browser. You can use this method to run
scripts, launch applications, and so on. Returns true immediately if
the application launch was successful.

It's probably doing the "opens this file using the appropriate application" instead of executing, and returns true because the file successfully opens (or is already open in its associated app). If I have a python script and do
f= new File("~/Documents/misc_scripts/getpixelrgb.py");
f.execute();
, it opens it in my script editor, even if the file's execute flags are set.
I'm on OSX, btw
In After Effects, there is system.callSystem() to execute command line commands, but I'm afraid that is absent in Illustrator (I'm assuming you're doing this for Illustrator because of the tag). Are you on OSX or Windows? There are ways around this, by making an executable .app (OSX) or .exe (Win) and calling that with execute(). If I were doing this, I'm on OSX and I'd make an AppleScript app that does 'do shell script' to make the ruby system call. On Windows, it's different. One solution you might like if you're on windows: ocra, which is ruby-specific (http://ocra.rubyforge.org/). It may be possible to run a .bat file on Windows that calls the ruby script, but I'm not sure.
[edit!]
Terribly sorry for the extraneous Windows info (for someone else, I guess). Just saw your note about being on OSX. So you might want to use the AppleScript solution.
[edit again]
So, if my ruby script ("test.rb") is:
#!/usr/bin/env ruby
print "Hello"
and my AppleScript is:
do shell script "cd /testing_folder/; ruby test.rb"
Then I get "Hello" returned in AppleScript, but ExtendScript will just return true.

Related

Labview System Exec VI different results than command window

When I try to run my executable (.exe) from the command window it works fine, but nothing happens when using the same commands in LabView's system exec VI. What do I need to change in my labview program?
I have tried calling the executable directly from the VI's command line, and have tried adjusting/deleting the working directory. I have not been able to start the .exe successfully yet.
You use "standard input" parameter in an incorrect way. Try this:

error while improving Chromedriver undetectability

Using C#, I have
driver = new ChromeDriver();
It gives:
System.ComponentModel.Win32Exception: The specified executable is not a valid application for this OS platform.
It worked before I changed something.
This answer specifies that to improve undetectability of Selenium, you have to run a certain PERL script. I ran it like so:
perl -pi -e 's/cdc_/dog_/g' C:\Users\user\source\repos\SleeveAce\packages\Selenium.WebDriver.ChromeDriver.91.0.4472.10100\driver\win32\chromedriver.exe
What do I do now? Before, the C# app was working perfectly, now it has that error. When I open the .exe as a notepad++ and search for cdc_, I find multiple instances, so I suppose the script is not working? I might be wrong though if the script was not supposed to do that.
EDIT: I have just tried changing all the cdc_ values in a hex editor as well with dog_. They were modified successfully. However, the error is still there.
EDIT2: Solved! See comments for explanation.
Additional info
Using Perl 5 v32
After running the script, nothing was shown (no
errors too!)

Task Scheduler + Intermittantly failing + How do you debug or get a dump + windows7

I have 5 scheduled tasks that are scheduled to run every day at 9.30am. The schedule is basically a vbs script that opens an excel workbook and runs a macro. These 5 schedules can run fine if i run them seperately and 9 times out of 10 they run fine if I simulataneously run them from task scheduler. I do this by highlighting them all and then pressing run.
But sometimes when the task scheduler is doing its schedule they will fail. Sometimes all of them fail, sometimes some of them fail, but most of the time they all succeed.
Once I okay the errors(will post this next time it occurs) I can see the excel.exe in my Processes in TaskManager they are left hanging. I cannot see them in Applications because I run them in the background. Whilst here I know I can right click on the excel.exe and do a Create Dump file, but not sure what to do with this.
What I am interested here is discovering why they are failing? How do I debug it? Can I get a dump? how do i do this? I am sure the code is not perfect but the fact that they run fine seperately and most of the time fine together I am wondering is some memory resource getting used up at this time. This is what I would like to find out.
I know that i could space them out to run every minute, and this is something I might do but I would like to answer my questions above first.
Note: The vbs script in question can be found here in a previous question I asked.
EDIT1 Some useful links I have come accross following Noodles answer:
WinDBG: The very basics
question re: reading dump file
EDIT2
If i right click on check for a solution I can click on View Technical Details and that gives me:
`
Description
Faulting Application Path: C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE
Problem signature
Problem Event Name: APPCRASH
Application Name: EXCEL.EXE
Application Version: 14.0.7128.5000
Application Timestamp: 5398dfdc
Fault Module Name: EXCEL.EXE
Fault Module Version: 14.0.7128.5000
Fault Module Timestamp: 5398dfdc
Exception Code: c0000005
Exception Offset: 0023e751
OS Version: 6.1.7601.2.1.0.256.4
Locale ID: 5129
Additional Information 1: 8bde
Additional Information 2: 8bdedbea09a2027adb218b0e009eebf2
Additional Information 3: d4c1
Additional Information 4: d4c17b47443511f18e75ae920aa444bd
Extra information about the problem
Bucket ID: 361665432
`
EDIT3 : A useful walkthough example with commands
Crash Dumps
Load in Windbg. Then File menu - Open Crash Dump. Type !analyze (note wrong spelling)
Debugging
You can also start in a debugger.
windbg or ntsd (ntsd is a console program and maybe installed). Both are also from Debugging Tools For Windows.
Download and install Debugging Tools for Windows
http://msdn.microsoft.com/en-us/windows/hardware/hh852363
Install the Windows SDK but just choose the debugging tools.
Create a folder called Symbols in C:\
Start Windbg. File menu - Symbol File Path and enter
srv*C:\symbols*http://msdl.microsoft.com/download/symbols
then
windbg -o -g -G c:\windows\system32\cmd.exe /k batfile.bat
You can press F12 to stop it and kb will show the call stack (g continues the program). If there's errors it will also stop and show them.
Type lm to list loaded modules, x ! to list the symbols and bp symbolname to set a breakpoint
If programming in VB6 then this environmental variable link=/pdb:none stores the symbols in the dll rather than seperate files. Make sure you compile the program with No Optimisations and tick the box for Create Symbolic Debug Info. Both on the Compile tab in the Project's Properties.
Also CoClassSyms (microsoft.com/msj/0399/hood/hood0399.aspx) can make symbols from type libraries.
You can schedule this command line instead.
Autostarting Programs in Debugger
You can also make windbg attach to any specific program when started. See gflags.exe. Only in GUI mode.
Errors
Also get the error number. TS keeps a history of runs and their errors. TS has a history tab.
.

VB.NET Process.Start failing

A problem that has been plaguing me for nearly a week now.
I am trying to get an install of IIS to take place through the command line in VB. I understand that i need to be setting up an Unattended xml script to call, but here is a fundamental bit that is confusing me:
If i run the command : ' start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer; ' it executes perfectly within CMD.exe.
If i add the command to a batch file and run the batch file, it runs perfectly.
If i call the command using : Dim myProcess As Process = Process.Start("cmd.exe", "/k start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;"), then it fails with an error of:
////////////////////////////////////////////////////////////////////////////////////////////////////////////
Operation failed with 0x8007000B ////
////
An attempt was made to run the program in an incorrect format ////
////////////////////////////////////////////////////////////////////////////////////////////////////////
If i call the batch file mentioned earlier, then i get the exact same error.
How can it work perfectly with the two first examples but fail when it is called through VB?
Thanks for any help!
Your VB.NET program is very likely to be running in 32-bit mode and will start the 32-bit version of cmd.exe. The one from c:\windows\syswow64 instead of the one from c:\windows\system32 that you used before. Getting BadImageFormatException starts to become likely.
Project + Properties, Compile tab, set the Target CPU to AnyCPU and untick the "Prefer 32-bit" option. On older versions of VS click the Advanced Compile Options button to get to the setting.

Using applescript to run terminal and passing a argument to compile

I am new to applescripts and i want to automate a little bit of my app.So here is the thing
1) I am using textwrangler as an editor
2) After writing code and saving it i want to compile the file by opening terminal from applescript.I already installed llvm compiler.
3) As textwrangler provides me the a menu in meubar to open script editor so after opening it i am using "tell application "Terminal" to activate" it opens terminal
4) i want " gcc myfilename.c " to be passed as argument from applescript so that as soon terminal opens this string should be passed as argument and executable is generated
Can i Do that through scripts? Please help.
Give this a try:
tell application "Terminal" to do script "gcc myfilename.c"
Running this without the Activate line you mentioned will still open Terminal if it isn't already open, but it won't bring it to the front. For that, Just turn the whole thing into a tell block and put the Activate back in there so it becomes:
tell application "Terminal"
activate
do script "gcc myfilename.c"
end tell