Sponsored Content
Top Forums Shell Programming and Scripting Need solution for my bash script executed localy for ssh remote machine Post 303046051 by Azura1003 on Wednesday 22nd of April 2020 11:24:49 AM
Old 04-22-2020
Thanks a lot for your reply see bellow normally the script doesn't looks like this I don't know why when I posted on this page the spaces disappeared.


I'm sorry I'm not that good in scripting still learning.


Can you explain me why you have added the variable with "\" ( \$) , is it the way to explain to the terminal that those variables needs to be executed on the remote shell ?



Quote:
Be aware of the escaped $ - chars for the variable expansion - without those, expansion would be done by the local shell, not the one on the remote node.
Can you clarify this part plz ?



Many thanks Smilie

Last edited by Azura1003; 04-22-2020 at 12:40 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

executng program on remote machine using ssh

I am trying to search and remove files from a list of servers. I want to find every occurence of this file on each machine and then remove it. If I execute the find command on the remote machine I would like to be able to pipe the output to xargs and remove the file. Does anyone know hat would be... (1 Reply)
Discussion started by: sewood
1 Replies

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

3. Shell Programming and Scripting

Cannot create variables via ssh on remote machine

Hello to all Background info: Local machine : Linux, /bin/bash Remote machine (for the user used for ssh) : SunOs, /bin/ksh (so we have different OS, different Shells) My problem : From the local host i execute $ var=bla $ result=$(ssh -q user@remote-machine " > echo \"this is... (12 Replies)
Discussion started by: black_fender
12 Replies

4. UNIX for Dummies Questions & Answers

how to use ssh to run shell script on a remote machine?

how to use ssh to run shell script on a remote machine? ssh user@remote sh ./script.unx i ran the above command ./script.unx HAS NOHUP COMMAND IN ITS BODY, I AM GETTING ERROR AS NOHUP NOT FOUND... i tried to run that script from remote server, its working fine do ineed to set... (6 Replies)
Discussion started by: only4satish
6 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

Mount fails (because remote machine is off) bash script stops

Hi, I'm trying to automate a couple of mounts. (I would do this in fstab, but the auto feature causes the virtual machine I'm running in to freeze when it boots up) If the machine I'm trying to connect to is OFF, I get the host unreachable error and then the bash script stops. The problem is... (3 Replies)
Discussion started by: jdilts
3 Replies

7. Red Hat

iptables applied in local machine, can't ssh remote machine after chain changed to DROP

I want to SSH to 192.168.1.15 Server from my machine, my ip was 192.168.1.99 Source Destination was UP, with IP 192.168.1.15. This is LAN Network there are 30 Machine's Connected to the network and working fine, I'm Playing around the local machine's because I need to apply the same rules in... (2 Replies)
Discussion started by: babinlonston
2 Replies

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

9. Shell Programming and Scripting

Check/get the exit status of a remote command executed on remote host through script

Geeks, Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s). Here's the complete... (5 Replies)
Discussion started by: lovesaikrishna
5 Replies

10. Shell Programming and Scripting

Ssh bash script exits without remote command completion

Hi, My goal is to connect from unix server A to windows server B and call a bat file on windows. I am able to succeed in remoting to windows and executing a command, the issue i am facing is the shell scrip is exiting without making sure of bat file success. Can you please help me in... (4 Replies)
Discussion started by: pxp018
4 Replies
cmexec(1m)																cmexec(1m)

NAME
cmexec - Execute process on a remote Serviceguard node. SYNOPSIS
cmexec node_name [-o outfile] [-t timeout] {[command] | [-k cmd_label]} DESCRIPTION
cmexec will execute a process on a remote Serviceguard node and return any output or return value. cmexec is limited in several ways. cmexec is best suited for situations where other remote execution facilities are not available. For a more full featured tool for remote execution within a cluster, see cexec(1m) provided by Distributed Systems Administration Utilities. To use this command, the local user must have the root access role on the remote node. For more information on Serviceguard access control policies, see the manual, Managing Serviceguard. The command will be executed in an environment which matches the local node. All environment variables defined locally will be available on the remote node. Output from stderr and stdout for the remote process will be combined and delivered in one transmission. This command should not be used for interactive commands or commands which will return large quantities of output. Input via stdin is not supported. Killing the cmexec process does not stop the remote execution of the command. cmexec should not be used on any command which may hang without specifying a timeout value. Options And Arguments cmexec supports the following arguments: -o outfile Write output to the specified file instead of stdout. -t timeout Kill the executed command if it does not exit within the specified timeout (in seconds) node_name Serviceguard node to execute command on. command Command to execute on remote node. May be quoted. -k cmd_label This option is only supported for applications provided by Hewlett-Packard. RETURN VALUE
cmexec returns the exit value for the remote command or 1 if there was an error communicating with the Serviceguard node. EXAMPLES
Execute an 'ls' in a remote directory. cmexec node ls /tmp AUTHOR
cmexec was developed by HP. SEE ALSO
rsh(1), ssh(1), cexec(1m), cmcp(1m), cmdo(1m), cmsync(1m), cmquerycl(1m), cmviewcl(1m) Requires Optional Serviceguard Software cmexec(1m)
All times are GMT -4. The time now is 10:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy