1

I have three Pis connected to a router with static IPs. An external hard drive is connected to one of them, and mounted to the other two over the network, so that all three can access the files on the hard drive.

My question is this: In the same vein that all the Pis can access files on the hard drive, even though they're not directly connected, could I create a symlink on Pi #1 to a binary on Pi #2 to execute the binary on Pi #2 from Pi #1? The goal here is to have have a script so that when Pi #1 completes its task, Pi #2 can start on its task. If there is another, easier way to accomplish this, I'm open to that as well.

2 Answers 2

1

If I understand your question right you could maybe use plink (Putty Link) which is a part of the PuTTY-package. With plink you can create a script on Pi#1 that uses plink to connects to Pi#2 and/or Pi#3 via ssh and executes commands and programs on them.

See how to use plink here

4
  • ...or just use ssh. If the remote Pi is called harry and you want to execute command cmd located in your home directory type ssh harry ./cmd.
    – joan
    Jul 19, 2014 at 21:45
  • I think this is what I'm looking for. I'll try it and report back.
    – Mike
    Jul 20, 2014 at 11:06
  • I looked at plink, and it looks like it's a Windows program for automating processes on the Pis. What I want is to do this without Windows, so I'll try joan's ssh solution.
    – Mike
    Jul 21, 2014 at 22:36
  • It exist for Linux, windows and Mac. pngu.mgh.harvard.edu/~purcell/plink/download.shtml
    – Ban Saie
    Nov 18, 2016 at 23:26
1

If my understanding of what you're wanting is incorrect; let me know. A long time ago, I had 2 computers with a shared NFS drive. I used MPI (parallel computing) to instruct both computers when to do what program but I think that may be a bit too advanced for what you're wanting. Here are some other options: - When P1 is finished, have it 'touch' a file on the net drive; have a simple perl script run on P2 all the time to check if the file exists. Might want to add a sleep in to pause the checking. (like this:

#!/usr/bin/perl 
$fname = "p1-ready";
 $net_dir = "/mnt/nfs-mount/";
 $f = $net_dir . $fname;
 while (1) { 
 if (-e $f) {
   #do something  
  } 
}

or you could have a script that runs in cron that checks for the file from P1 and if it finds it, start the next program. Hope this helps.

EDIT: Just thought of another way; assuming the script/program on P1 is called "P1app" and on P2 is "P2app". Run ssh-keygen on both computers; leaving nothing for a password (just hit enter) then copy .ssh/id_rsa.pub from P1 to P2 and type "cat id_rsa.pub >> ~/.ssh/authorized_keys" and do the reverse on P2 to P1. This will allow that user to ssh from P1 to P2 w/o needing to enter a password. Next, have a shell script on P1:

/usr/local/bin/P1app && ssh -l USER_ON_P2 P2_IP P2app

What this does is start P1app and if it finished ok (the && means the second part won't execute unless the P1app ran without issues) it will then start P2app via a ssh.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.