Presently i am running a script from my local box(i.e jumpbox) to all the remote machines.Basically fetching basic queries like pwd,mkdir,touch etc and i am able to successfully fetch it from my local machine.But when i want to check certain database related queries like the dbstat command,calling particular shell script on the remote server from my local machine i am not able to fetch it.it says path and directory not found.
from my local machine i fetch the below command
ssh <remote machine name> 'bash-s' < 'my script'
content of my script as below
#/bin/bash
echo "++check the pwd directory++"
pwd
echo "+++ swith to user abc+++"
sudo su - abc
echo "+++ execute the script as user abc+++"
/home/abc/xyz.sh
echo "+++ check the db status as user abc+++"
dbstat
Unfortunately i am unable to fetch the details for the database status and the shell script executed on the remote machine.Hence need you kind assistance.
Hi Whizkid,
yes, your logged in on the remote machine, but with the same user as on your jumpbox, right?
Check this with the whoami command before or after the pwd command in "my script".
With su - abc you (want to) become another user, namely abc.
Usually one needs to provide a password for the new user, unless you run the su command with root user.
I suggest to place the whoami command between su - abc and /home/abc/xyz.sh , so you can see if the su command was successful.
I am already logged in with user abc..but have difficulties running scripts (ending with .sh) or any database commands like (dbstat) from external system.
@ Rudy..
Hope you are asking me about the PATH @ remote server right ?
Yes i can directly do a
'dbstat'
command once i logged in the remote server directly. (steps as provided below)
ssh < remote server name>
sudo su - abc
dbstat
for the PATH at remote server is already provide in my earlier mail chain
Between I am trying to perform the above activity thru my jumpbox using the ssh
---------- Post updated at 07:17 AM ---------- Previous update was at 07:07 AM ----------
@Rudi..
Presently i am getting the below log for dbstat when i execute the script thr ssh(from my local machine(jump box) to remote server)
++checking dbstat++
-nologin[8]: dbstat: not found [No such file or directory]
So - is the PATH when logging in interactively the same as when running the script remotely? Can you issue the whereis dbstat command and post the result?