Problems Running from Command Line

I have been having a few problems getting my scripts running from the command line. I have narrowed things down a bit so now I’d like to share with you folks.

First up is a simple script that, when run from the Eggplant GUI, runs just fine. So far, so good.

Now I try to run from the command line:

$ /Applications/ QACM\ Cornerstone/psl/eggplant/PSL3.suite/Scripts/textgen.script -host
2009-03-02 09:48:10.285 runscript[337:10b] Approved License: Name = com.zzz.1, Remark = , Serial = xxx, Users = 1
runscript (4.12) running in FULL mode on Host:yyy.
2009-03-02 09:48:10.961 runscript[337:10b] Exception running :
Invalid File: Invalid file type or file not found (QACM Cornerstone/psl/eggplant/PSL3.suite/Scripts/textgen.script)

I certainly can read the file:

$ cat QACM\ Cornerstone/psl/eggplant/PSL3.suite/Scripts/textgen.script > /dev/null

It’s some permissions problem I can’t imagine so I’ll try sudo, which gets us farther but still has a problem:

$ sudo /Applications/ QACM\ Cornerstone/psl/eggplant/PSL3.suite/Scripts/textgen.script -host
2009-03-02 09:37:28.147 runscript[303:c0b] Approved License: Name = com.zzz.1, Remark = , Serial = xxx, Users = 1
runscript (4.12) running in FULL mode on Host:yyy.
2009-03-02 09:37:34.907 runscript[303:c0b] STUnknownMessage:
ERROR: No Such Command: ‘startbrowser’
2009-03-02 09:37:35.910 runscript[303:c0b] Completed EggplantTestScript PSL3.suite - textgen.script

“startbrowser” is a script that is not in PSL3.suite, it is in another suite that has been put into InitialSuites. I suspect that runscript isn’t setting the folder global property so I set it explicitly in the script instead of relying on the setting in Eggplant’s preferences but that doesn’t make a difference. However, if I go into the script and explicitly set InitialSuites to the full path of the suite rather than just the suite name, that does work…sort of. At least it gets me farther than before.

So my questions are:

Why am I having to run the script as root?

Why am I having to set the full suite path in InitialSuites rather than relying on the folder global property set in Eggplant’s preferences?

I’m not 100% sure but I think the main problem all stems from the original call to Eggplant (with the script name) and using a relative path there (instead of an absolute path).

It’s probably that your user doesn’t have the current working directory (CWD) in the PATH environment variable. In this case doing a SUDO helps because the root user does have that.

Try replacing the script name with an absolute path (starting with a /).

Well whaddya know? That solved pretty much everything. Thanks! I cannot imagine why that would matter but now I know it does.