Q:

Run bash script to control JBoss from Windows using PLink.exe?

I created a windows batch file with the following content:
plink -batch PuttySaveSessionName -pw thePassword "bash stop.sh"

stop.sh is located in the home directory of the linux machine I log in to, and has the following content:
echo "starting..."
cd //path_to_jboss_dir/jboss/bin
./spcrun.stop
echo "finished"

If I execute the Windows batch file I receive the following output and the server is still running:
starting...
finished
JAVA_HOME system property is undefined.
Please define JAVA_HOME and start JBoss again.

If I use putty to log in, and follow the commands above, the server shuts down.
I need the same behavior using pLink from Windows.  Any ideas on what the problem is?

A:

Executing "bash cmd" starts a non-interactive shell session; not all of your shell setup files will be parsed.
You can either execute bash -l cmd or move the required settings from your profile (probably $HOME/.profile) to your rc file ($HOME/.bashrc).

