Can't run a java command on linux box connected by ssh
vu pham
vu at sivell.com
Tue Nov 25 09:17:20 PST 2008
Joglekar wrote:
> Hi All,
>
> Here is what i am trying to do:
>
> I have a linux box to which i want to connect to and run a java application
> there.
> To connect to the linux box, i am using the 'ssh'.
>
> I am sitting on a linux box and i am 'ssh'ing into another linux box, on the
> one i am trying to connect, i have already compiled the application, and it
> runs well on that box when tested directly.
>
> USER at server1$ ssh USER at SERVER2 . runap
>
> the runap is a shell script and it runs a java command.
>
> If i log into SERVER2 directly and run this scripts, it runs fine, however
> when i am trying to get into SERVER2 and then run the script, it fails. It
> gives the following error:
>
> java: command not found
>
> can someone tell me what is it that i am missing?
>
Depending on the shell you have on the remote server, different profiles
can be loaded therefore you can have different PATH env. I use bash,
and ssh loads the remote .bashrc, but not .bash_profile therefore my
$PATH in .bash_profile is not loaded when I use ssh remoteserver command.
For example, my command "a" just has "echo $PATH". It shows different
output under different env.
// my current PATH
[vu at ef ~]$ . a
/home/vu/jdk1.6.0_07/bin:/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin:/home/vu/bin
// my PATH when I execute the command a via ssh
[vu at ef ~]$ ssh vu at localhost . a
vu at localhost's password:
/usr/local/bin:/bin:/usr/bin
You can see the path to my local JDK is missing in the latter case. If I
had the java command in "a", I would also get "command not found" when
remotely running a via ssh, if I do not have java in other listed paths.
hth,
Vu
More information about the Linux-users
mailing list