Sorry for not being clear on my initial post. Below are the details:
jar=test.jar
md5=test.jar.md5
now i want to do the below:
#1. md5sum test.jar (exists in remote server x)
#2. cat test.jar.md5 (exists in remote server x)
#3. Now from my local machine i want to ssh to the remote server x and then want to check whether md5sum is matching
I tried the below:
==================
========================
output:
-----------
-- when i cat the file its displaying the result without any issue
-- but when i do the same inside the if condition its throwing permission error
Note: On the remote server I have all the required permissions to read and execute these jar and md5 files.
I tried alot of time on this but couldn't able to find the issue. Could someone help me here.
Thanks
Moderator's Comments:
Please use next time code tags for your cade and data, thanks
Since you are using double quotes, your two command substitutions are being executed on your local computer. Try single quotes
== is not syntactically correct. a single = should be used
The if statement with the exit commands is reproducing the exact return codes that the test command would produce anyway, so you can just leave it out.
it is best to quote both sides of a string comparison in a test statement
Still consider using $(...) instead of `...` (unless you are using a classic Bourne shell). It saves you quoting troubles..
Combining all this into one, try something like:
You can add 2>/dev/null is you want to suppress messages..
In addition, if the files are in the same directory you do not need to use a test, you could also use:
or
(or alternatively use >/dev/null 2>&1) to quiesce the output and only use the return code..
This User Gave Thanks to Scrutinizer For This Post:
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)
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)
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)
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)
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)
Hello again :) ,
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:
ssh user@host "cd ScriptDir; ./Script.sh"
and the... (6 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)
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)
I have a script that connects to remote servers using a public key. Some of the servers are not set up for the public key and I receive the following when I attempt to ssh: The authenticity of host 'XXX' can't be established.
RSA key fingerprint is... (1 Reply)
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)