You must put the remote command in quotes, so the local shell sees a string.
E.g. in double-quotes so "$var" is substituted in the string (on the local host).
I'd like to execute .profile as well as i need this variable ${AppsPass} value to be substituted variables dynamically but the below code is not executing it properly.
You might be better to have a script on the target server that:-
Calls .profile
Executes the command
That way, your ssh is kept neater. Is this an option, or will there be a wide variety of calls, of which this is a test case, and you might want to repeat it for many other target servers.
It's all in the quoting to make sure that the right shell evaluates the variables.
What errors are you getting back?
Can you simplify the ssh call to just display what would be executed so you can see what is getting passed where, and as what value?
Perhaps something more like:-
Of course, you might just have a spelling mistake in ADMIN_SCIRPTS_HOME and that would be an easy fix.
Yes,I'm calling .profile and executing ssh command in one line but as per my experience i've to include .profile in single quotes only then it works but otherway around in dobule quotes variables are not getting expanded because of single quotes.
I've tried even simpler. As i said above problem with single quotes and double quotes
./test.sh: line 2: /admin/scripts/XXXXXXXX/adcmctl.sh: No such file or directory
I've fixed Admin_scripts_home spelling already sorry that was a typo above.
Regards
Bala
Last edited by Y.balakrishna; 02-03-2014 at 08:13 AM..
How to execute setDomainEnv.sh in wblogic via ssh on remote server in shell script
we execute setDomainEnv.sh manually as . ./setDomainEnv.sh from its location ie /opt/SP/users/domian/bin"
My approach is not working.
Please advise.
#!/bin/bash
set -x
base="/opt/SP/users/d1/bin"... (5 Replies)
I need to copy python script file to around 100 servers using expect script.
1. Copy script to my user home first(/home/myhome) on each remote server
2. change permissions on copied file to 766.
3. sudo to appuser1 account on remote server. copy script file from my user home to /usr/bin/... (1 Reply)
Hi Friends,
We have a application "getstatus" which needs to run on application prompt.
But it is not working with shell script.
Example:
Unix Root Prompt#
execute "crp" to go to application prompt
CRP>getstatus
displays output of app health
CRP>exit
Unix Root Prompt#
Script , which... (2 Replies)
I want to execute a shell script(set of commands) on remote machine and that script takes input from text file(local machine). Please refer below:
ssh user@hostname 'bash -s'< ./test.sh file.txt
But i got the error file.txt doesn't exist.
Can anyone help me on this.
Content of test.sh:
... (2 Replies)
Hello,
I am running into few issues, please suggest me what I am missing.
I am running this script on a linux host.
Main idea of this script is to, login to each host via ssh and get uid of user, service user that I trying to run this script, has already deployed ssh keys and provide sudo... (8 Replies)
Help please!!
I want to use ssh to execute a remote exe and while it's running I want to query for the process ID of the exe (2 different ssh commands)
1. sshpass -p "<passwd>" ssh -f -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@<ipaddress> nohup /tmp/mmds_asyn &
2.... (0 Replies)
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)
Hi all!
I am trying to write a script that will check if a certain directory is available at several different nodes and then do stuff in it .....
On the beginning of the script I give as a variable the directory and the number of the nodes and then I loop like this:
for... (3 Replies)
I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config.
I am not sure if I can do this with BASH scripting.
I have set up password less login by adding my public key to authorized_keys file, it works.
I am a little... (1 Reply)
Greetings Friends,
Suppose I wish to invoke some shell level commands inside an awk script how to do that?
say I wish to use : "wc" on a record to count number of characters in a record
Any clues?
Thanks,
Rishi (1 Reply)