Executing remote application using ssh without full reference to its location


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing remote application using ssh without full reference to its location
# 1  
Old 03-20-2011
Executing remote application using ssh without full reference to its location

Hello again Smilie ,

My script has an ssh command to run a script on a remote machine. The script has commands such as sqlplus and unzip. However, the return I get in my own terminal says it can't find sqlplus and unzip.

the ssh command is:
Code:
ssh user@host "cd ScriptDir; ./Script.sh"

and the result I get is:
Code:
./Script.sh[74]: sqlplus:  not found

Thanks.
# 2  
Old 03-20-2011
You need to get your script (or the ssh command) to set the Oracle environment.

i.e.
Code:
$ ssh root@ora1 "which sqlplus"      
which: no sqlplus in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin)

$ ssh root@ora1 "ORAENV_ASK=NO; . oraenv DB1; which sqlplus"  
/u01/app/oracle/product/10.2/client/bin/sqlplus

This User Gave Thanks to Scott For This Post:
# 3  
Old 03-20-2011
There is a bunch of things exported upon normal login (not just to run a command). Would it be fixed by adding
Code:
. .profile

before the command which runs the script?
# 4  
Old 03-20-2011
Most likely. Give it a go!
# 5  
Old 03-20-2011
It doesn't fix it. But I found the reason why.

Code:
ssh user@host echo $PATH

does not have the oracle or unzip paths, but
Code:
user@host:> echo $PATH

does.

Now all I have to do is make sure the $PATH is loaded completely.
# 6  
Old 03-20-2011
I thought we agreed (in your other thread), that to access a remote variable you need to escape it:

Code:
ssh user@host echo \$PATH

# 7  
Old 03-20-2011
Ok now it's working.

We went off on the wrong track after the . .profile post. It was a link to another location. Somehow ssh doesn't like to load link files. To fix it I just used
Code:
. /location/to/which/it/was/pointing/realProfile

Thanks again for the help.
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

Issue in executing cat (remote ssh)

Hi, I need to ssh remotely to a machine and cat a file assign the value to a variable Script: #!/bin/bash -x value=`cat config.txt` echo "$value" ssh me@xxx.host.com "valu='cat /export/home/test.md5'; echo "$valu"" | tee Execution: $ ./x ++ cat config.txt + value='touch me' +... (5 Replies)
Discussion started by: close2jay
5 Replies

3. Linux

Executing a script in remote machine through ssh

How to execute a script in remote machine through ssh I have a script test.sh which does some backup activity in remote machine. Wanted to keep backup also in remote machine. ssh -l username <remote machine> "commands to be exceuted as ; separted" but how to put the script in the place of... (5 Replies)
Discussion started by: sanvel
5 Replies

4. 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

5. Shell Programming and Scripting

executing commands in remote server using ssh

I have some commands which need to be executed in remote machine. I have Linux Server from where I need to connect to Solaris server using ssh and then declare some variable over there and run some commands. I don't want to call a script which is present in Solaris server from Linux server... (7 Replies)
Discussion started by: maitree
7 Replies

6. UNIX for Dummies Questions & Answers

how to stay in remote shell after executing commands in ssh?

the ssh calling convention: ssh <server> If I put commands in the section, ssh will execute them immediately after logging in and return to local shell. I want to stay in the remote shell after executing these commands. How can I achieve this? Thanks for all. (1 Reply)
Discussion started by: hplonlien
1 Replies

7. Shell Programming and Scripting

Kill remote application launched via SSH command

Hi All I launch some application in a remote machine using ssh EXAMPLE ssh -X myname@mycompany@RemoteServerIp 'myApplicationName' When I want to kill the application I hit CTRL+C and I see a message 'Killed by signal 2'. Unfortunately on the remote machine the application is not really... (1 Reply)
Discussion started by: manustone
1 Replies

8. Shell Programming and Scripting

Executing a script on a remote system via SSH

Hello all, I have a relatively simple script I wrote to generate a count of errors broken down. What I would like to do is execute this script from another server so that I don't actually have to log in to the server to run the check. The script on what we'll call "Server A" is: ... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

9. Shell Programming and Scripting

Executing awk in a remote server using ssh

Hello Everybody, I'm facing a weird problem with the awk command. I'm trying to execute a simple awk command as follows, echo 1 2 | awk '{print $2}' This command prints the output 2. When i try to execute the same command in a remote server using ssh as follows, ssh user@host... (2 Replies)
Discussion started by: karthikv
2 Replies

10. Shell Programming and Scripting

executing a remote location script from local server

hi i am having two servers one is local and remote(FTP)server.from local server i have to connect to remote server and execute a shell script i want to run a shell script(remote location) from my local server i am having some knowledge on ftp but i am not getting the result .please give ... (2 Replies)
Discussion started by: srivsn
2 Replies
Login or Register to Ask a Question