It's difficult to troubleshoot this without seeing the full script. I will give you an example of my script and how I code it:
Here is code snippet where I declare the variables and use parameters:
echo INFO 1.0 "Declare Variables"
#Get Parameter Values input by the user
while getopts d:t:p:l:m:s: o
case "$o" in
#Rest of the script goes here
Now here is the screenshot of the parameters tab in my script:
Hope that helps in resolving your issue.
only deploys will put something in the Transactions logs - nsh scripts/jobs will not.
can you run your script from the commandline w/ the same arguments? does that work?
you can try running it like nsh -x <script> <args> to get more debug info.
Thanks for you post I used your example to verify I'm doing everything right, my code was pretty much the same and I even changed it be the same as yours , and started flags with parameters (I did not before) just to be sure I'm set up the same way as you.
Yet I still get the same String index out of range: 0
Then I removed all parameters and hard-coded values in the script and still getting the error so it must be something else I'll have to dig further. Problem is running it manually in NSH window is never a problem - only when setting it up to run as NSHscriptJob in bladelogic.
Yes I can run my scipt from command line (in NSH window) just fine, no problems.
Only becomes a problem when running as NSHScriptJob (now with or without parameters)
Script Type "Execute the script separately agains each host (using"runscript")
Target server is the bladelogic appserver itself (one host)
The error String index out of range: 0 happens immediately , the script never begins to do anything - it's somethign in the way its executed by bladelogic that's causing the error but I can't figure out what
and there's no logging as you mentioned nsh script job do not log to Transactions log.
Mystery solved:String index out of range: 0 was caused by the very first line in the script which happened to be blank ?!
I'm new to nsh and shell scripting in general and am just curious, is it "by design" (can't have blank first line in the scipt?
Thanks everybody for your help
First line in any SHELL script should define the SHELL to be used.
e.g. for NSH on my servers
the #! states use this SHELL to process this script.
You can have a blank line as first line of script, this would cause the script to be run using the current command line shell.
This can be a problem when the script is run by system process because it doeesn't execute or set any environment variables i.e SHELL="".
Hope this helps you understand it a little better.
OK, got you I did not know blank fist line was that significant.