Shell script help to execute ssh remote commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script help to execute ssh remote commands
# 8  
Old 02-03-2014
So, have you tried my suggestion to display what is or not getting set, and are you getting any output that would help?

Did you consider the spelling of your variable?




Robin

Last edited by rbatte1; 02-03-2014 at 07:07 AM.. Reason: Grammar
# 9  
Old 02-03-2014
The ~ expansion only works in bash and ksh.
Because the first shell on the remote system starts in the user's home directory, one can safely do
Code:
. .profile

NB: .profile is made for interactive logins, so bares a risk of malfunction.
# 10  
Old 02-04-2014
Hi,

I've tried the below code this .profile is being executed but its not expanding this variable value ${AppsPass}.

Code:
ssh -q -o BatchMode=yes -o PasswordAuthentication=no XXXXX@XXXXXX '. ./.profile 2>/dev/null;"sh $ADMIN_SCRIPTS_HOME/adcmctl.sh stop apps/${AppsPass}"||"sh $COMMON_TOP/admin/scripts/$CONTEXT_NAME/adcmctl.sh stop apps/${AppsPass}"'

Regards
Bala
# 11  
Old 02-04-2014
Please, for each variables on the remote system, say if they are to be defined from the calling system or by the .profile on the remote system!
# 12  
Old 02-04-2014
Hi All,

I've solved the problem somehow .. thanks for all your efforts last but not least.

I'd like to limit my search of below text only to last 3 lines if its finds it should print if not it should exist .. Can anybody help that.

Code:
grep "Shutting down concurrent managers" adcmctl.txt | tail -1

# 13  
Old 02-04-2014
Change the order, so the grep is the last component in the pipe, and determines the exit status that if can use
Code:
if tail -3 adcmctl.txt | grep "Shutting down concurrent managers"
then
  : # nothing to add
else
  exit # not found
fi

This User Gave Thanks to MadeInGermany For This Post:
# 14  
Old 02-04-2014
Thanks Germany .. this idea didn't cross my rusty mind. thank you so much.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to execute setDomainEnv.sh in wblogic via ssh on remote server in shell script?

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)
Discussion started by: abhaydas
5 Replies

2. Shell Programming and Scripting

How to execute commands on remote server using expect script?

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)
Discussion started by: kchinnam
1 Replies

3. Shell Programming and Scripting

How to execute application commands with shell script?

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)
Discussion started by: suresh3566
2 Replies

4. Shell Programming and Scripting

Execute shell script on remote machine

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)
Discussion started by: manishtri88
2 Replies

5. Shell Programming and Scripting

bash script to execute a command remote servers using ssh

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)
Discussion started by: bobby320
8 Replies

6. Shell Programming and Scripting

Using ssh to execute a remote script in the background

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)
Discussion started by: rvompoluTMW
0 Replies

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

8. Shell Programming and Scripting

Execute ssh commands through bash script

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)
Discussion started by: idet2
3 Replies

9. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

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)
Discussion started by: bash_in_my_head
1 Replies

10. Shell Programming and Scripting

how to execute shell commands in awk script?

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)
Discussion started by: RishiPahuja
1 Replies
Login or Register to Ask a Question