I need to run this command from Ubuntu machine: ssh user@hostip "which mvn"
to show excutable path of Maven , but it show nothing
root@~: ssh user@hostip "which mvn"
root@~:
I check command which mvn
on remote host it show me :
root@~: which mvn
/usr/share/mvn
root@~:
I try to sourcing .bashrc
when excute ssh command but no luck:
root@~: ssh user@hostip ". ~/.bashrc;which mvn"
root@~:
In ./bashrc also have nothing about maven PATH configure
So , what i have to do ?
root@~: ssh user@hostip "which mvn"
When you run ssh
and specify a command to invoke on the remote system, ssh
by default doesn't allocate a PTY (pseudo-TTY) for the remote session. Shells like bash
will detect that they're running without a TTY, and this will alter how the shell process initializes itself.
In your case, whatever command adds "/usr/share" to your remote PATH is probably not running for non-interactive sessions (sessions without a TTY). You can probably solve this by telling ssh
to request a TTY for the remote session:
ssh -tt user@hostip "which mvn"
The -t
option tells ssh
to request a TTY for the remote session. This would cause your remote shell instance to initialize itself for an interactive session. Refer to the ssh manual for details on the -t
option.
If this doesn't solve the problem, you will need to find the point in your shell configuration files on the remote server (.bash_profile, .bashrc, etc.) where /usr/share
is being added to your PATH, and make sure that step is performed for non-interactive sessions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.