executing a command using ssh


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers executing a command using ssh
# 1  
Old 11-23-2011
executing a command using ssh

Hi All,

I am trying to execute a command using ssh as below.

Code:
ssh user123@servername "which ctmcontb"

It is gving the error as below

Code:
no ctmcontb in /usr/bin /usr/sbin /opt/sysadm/bin

Not sure from where the PATH is getting picked up.

But When I login direclty to the server I am able to find the command.

Code:
which ctmcontb
/app/controlm/ctm/exe_HP-UX-11/ctmcontb

Please let me know how the path is getting set.

Same is the case with both HP and sun servers.

Last edited by pludi; 11-23-2011 at 06:18 AM..
# 2  
Old 11-23-2011
Hi,

already tried to insert a PATH definition in .bashrc located in the user's remote home directory? (I think ssh in non-interactive mode reads .bashrc on the remote server to initialize the session parameters).

see ya
fra
# 3  
Old 11-23-2011
is it correct to assume that you used the same ids on both boxes?
# 4  
Old 11-23-2011
How did you log on directly? Using ssh or telnet/remsh?
# 5  
Old 11-25-2011
Yes. I used same ID to login to the server.

I used ssh to connect direclty to the server and ssh username@servername which ctmcontb.
# 6  
Old 11-28-2011
check path settings. id probably do this and compare the results from each servers

Code:
set | grep -i path

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remote script via SSH not executing

I have worked on multiple scenarios to execute remote script via ssh. This problem I am not able to resolve. 2 linux hosts. Server1, Server2 on Server1 I have script called ~/scripts/start_standalone.sh XXXX cd $JBOSS_HOME NODENAME=xyz; IP_ADDR=`hostname`; MGMT_IPADDR=`hostname`;... (3 Replies)
Discussion started by: oraclermanpt
3 Replies

2. Shell Programming and Scripting

Query on executing awk using SSH

Hi All, Im trying to find the count of process running on remote server using SSH. Below command dosen't work. ssh -q user@host "ps -ef | grep "pattern" | grep -v 'grep' | awk '{print $2}'|wc -l" But below command works. ssh -q user@host "ps -ef | grep "pattern" | grep -v... (1 Reply)
Discussion started by: Girish19
1 Replies

3. Shell Programming and Scripting

Executing remote commands via ssh

Hi, I'm tryin to write a script that will collect information about a remote servers, put them into variables and print them to screen. # /usr/bin/bash ls $1 > /dev/null 2>/dev/null if then echo "$1 is file" for server in $(cat $1) do # echo $server ... (5 Replies)
Discussion started by: moshesa
5 Replies

4. Shell Programming and Scripting

executing command in a remote machine through ssh - shell script

Hi All, i have two machines like x and y . my requirement is i should connect to machine Y from x through ssh connection . and do some operation such as copy and move and delete files in Y machine . i tried with this code but it is doing in machine x only . and i need to exit from Y when... (1 Reply)
Discussion started by: rateeshkumar
1 Replies

5. Shell Programming and Scripting

executing commands over ssh

Hi I am trying to send a command over ssh with a parameter but the shell fails to expand the command properly any ideas what am i doing wrong with this. This is ssh on AIX for i in 71 72 73 74 75 do for server in server1 server2 do somestr="Some String" echo "$server... (3 Replies)
Discussion started by: xiamin
3 Replies

6. Shell Programming and Scripting

prevent ssh from executing result in shell

Hi, I am writing a script on Solaris 10 and want to execute a remote ssh command. Normally this command should just return the value 0000000000002356 but when using ssh it seems it is passing the result to the shell to execute. ssh root@10.5.112.145 `/usr/bin/nawk -F\, '$1=="USG" && $2=="01"... (3 Replies)
Discussion started by: borderblaster
3 Replies

7. Shell Programming and Scripting

ssh and executing a for loop

Hi all, I am trying to run a script which is expected to do: on the remote machine, There are two directories /export/home/abc1,/export/home/abc2 i am trying to do, ssh SERVERNAME "for i in `ls -l /export/home/abc*|awk '{print $9}'`; do cd $i; ls -l; done" But its not working ,iam... (11 Replies)
Discussion started by: Jartan
11 Replies

8. Shell Programming and Scripting

Problem with executing script using ssh

I'm writing a script which is meant to ssh into a remote machine, sed a file there, and write the output to a new file on the remote machine. Obviously the easy way to do this is to write and execute the script on the remote machine, but I'm trying to do this all via ssh since I like to keep and... (4 Replies)
Discussion started by: maethlin
4 Replies

9. Shell Programming and Scripting

Error while executing glance using ssh

Hi, I'm running glance ussing ssh from a "HP-UX" machine for a Sun machine. Here is a sample code:- x:- HP-UX y:- Sun Extracting a value from glance outuput. ssh x@y "/opt/perf/bin/glance -f -adviser_only -iterations 2 -maxpages 1 > glance.op ; echo `head -1 glance.op | a wk '{print... (0 Replies)
Discussion started by: bishweshwar
0 Replies

10. UNIX for Advanced & Expert Users

executing .profile with ssh

Hi, How do I get all my profile settings when connecting with ssh? (5 Replies)
Discussion started by: rein
5 Replies
Login or Register to Ask a Question