Remote if find call failing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remote if find call failing
# 1  
Old 01-27-2011
Remote if find call failing

Hi folks. I know this is going to be one of those ones where I just need to stick a bracket or a single quote somewhere to fix, but it's killing me to try and work out why it's failing.

This is the part of my script that isn't working properly:

Code:
ssh serverx "touch -t $(date +%Y%m%d)${HOURMINVAR} file1;
          if [ `find file2 -newer file1` ];
          then echo 'Message 1';
          else echo 'Message 2'; fi;"

And this is the message when you run it:

Code:
find: cannot access file1
dlam@serverx's password: $

As you can see, for some reason if is performing the "find" command before it performs the "ssh" bit. It works fine if I use single quotes instead of double quotes around the commands, but then obviously ignores the $HOURMINVAR variable so it uses the incorrect values for the "touch" part.

So...is there a way I can send the variable using a single quote around the whole command - or can anyone see where I am going wrong with the "find" command when wrapped in double quotes?

Hope that makes sense. Thanks in advance!
# 2  
Old 01-27-2011
Code:
ssh serverx "touch -t $(date +%Y%m%d)${HOURMINVAR} file1;
          if [ `find file2 -newer file1` ];
          then echo 'Message 1';
          else echo 'Message 2'; fi;"

Any variables and such are being substituted before the string gets transmitted, that includes backticks. You can escape them like so:
Code:
ssh serverx "touch -t $(date +%Y%m%d)${HOURMINVAR} file1;
          if [ \`find file2 -newer file1\` ];
          then echo 'Message 1';
          else echo 'Message 2'; fi;"

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 01-27-2011
Ha - that's ridiculous! I was sure I'd tried escape characters there as part of my whole afternoon trying to get it working. But I've done what you suggested and it's worked perfectly.

Corona688 I could kiss you (if it wasnt for the restraining order)

Thanks very much for your help. Case closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script failing to run successfully on remote node

Hi guys, I have a scenario where i want to run a script from Node A. It ssh's into Node B and runs some awk commands there plus deposiriting the output on Node B. Challenge is that the awk commands run properly when executed locally on Node B but fail when within the script on Node B. I do not... (0 Replies)
Discussion started by: jerkesler
0 Replies

2. Programming

Is it possible to call remote function in another daemon?

Hi, Is it possible to call a remote function in another daemon? Here is the setup: I have two daemons daemon A with function "s" and daemon B with function "k". I need a way function "s" from daemon A to call a function "k" from daemon B and pass some arguments. When the request is ... (13 Replies)
Discussion started by: rcbandit
13 Replies

3. Shell Programming and Scripting

Remote call not hiding password fields

Not sure on the description, but here is a quick rundown. I have 2 servers, we'll call them serverA serverB On serverB, I am calling a script that inside it has the following: ssh srvdsadm@serverB sudo -u dsadm /opt/apps/DataStage/scripts/autoDeploy.sh ${projName} ${subProjVar}... (1 Reply)
Discussion started by: cbo0485
1 Replies

4. Programming

help remote procedure call

am beginig with unix c code for sun remote procedure call You are to write a program using RPC facility to do the following: 1- The clients reads in a variable length array from the command line 2- The client offers a menu for the user to choose what to do with the array: a. Sort the array... (1 Reply)
Discussion started by: auto2000
1 Replies

5. UNIX for Dummies Questions & Answers

help remote procedure call

i am beginig with unix c code for sun remote procedure call to do the following: 1- The clients reads in a variable length array from the command line 2- The client offers a menu for the user to choose what to do with the array: a. Sort the array b. Add the array c. Find max d. Find... (1 Reply)
Discussion started by: auto2000
1 Replies

6. Programming

help remote procedure call

i am beginig with unix c code for sun remote procedure call to do the following: 1- The clients reads in a variable length array from the command line 2- The client offers a menu for the user to choose what to do with the array: a. Sort the array b. Add the array c. Find max d. Find... (1 Reply)
Discussion started by: auto2000
1 Replies

7. UNIX for Advanced & Expert Users

help remote procedure call

i am beginig with unix c code for sun remote procedure call to do the following: 1- The clients reads in a variable length array from the command line 2- The client offers a menu for the user to choose what to do with the array: a. Sort the array b. Add the array c. Find max d. Find... (1 Reply)
Discussion started by: auto2000
1 Replies

8. Solaris

How to get RPC(Remote Proceedure Call) values?

Guys, Help me out in getting the RPC resource values of the system. By running the ipcs command i get the HEXA values of the IPC(Inter Process Communication) values in the system like q 12760 0x10fe4d88 --rw-rw-rw- a-1982 cts m 686089 0x10fe4d48 --rw-rw-rw- a-1982 ... (2 Replies)
Discussion started by: meheretoknow
2 Replies

9. Shell Programming and Scripting

csh failing to call an 2 embedded csh script

I have an extraordinary problem with a csh script.....(feel free to berate the use of this but I'm modifying an existing bunch of them) Anyway, I have a master csh script which in turn calls a second csh script. This second csh script is below. Within this second script are two compiled C++... (1 Reply)
Discussion started by: pollsizer
1 Replies
Login or Register to Ask a Question