0

This is a messy situation and I may (as in allowed) not explain why I need to do this but I do need it (if possible).

M1, M2 and M3 are all Linux.

I have a machine M1 on one side of the world that is connecting to M2 using ssh. The command executed on M2 creates a big zip file which has to be FTPd to M3.

It is a requirement that the file must be sent from M2 to M1 before it is shipped to M3. Yes, it would be faster and simpler if I could transfer it from M2 to M3, but that's not an option.

Is it possible to set something up that will allow a file to be copied from M2 to a location on M1 such that any file that appears there will automagically get FTPd directly to M3?

The transfer from M2 to M3 can be a regular cp command because the location on M2 is an NFS mount point visible from M1. There is no access to M3 except via FTP.

Is there a magic ssh tunnel incantation that I can use? Or are there any other suggestions? The bottom line is that the command originates on M1 but the transfer must be from M1 to M3.

user680453
  • 39
  • 1
  • If you already have a share between M1 and M2, and run everything from M1, I don't see what problem you have. Generate on M2, move it to the share, exit SSH and ftp from M1. – Mat Apr 17 '12 at 19:32
  • Do you have command level access to M2? – Learath2 Apr 17 '12 at 20:48

2 Answers2

0

1) FTP deals with files and directories. NFS exports files and directories.

Your goal is to figure out how you can use files and directories. Don't even think about nonsense like "tunnels", unless you absolutely have to.

2) Enable NFS wherever possible, and use ftp where you can't use NFS. I guess use carrier pigeon, quantum file transfer or telepathy where you can't use FTP ;)

3) One common, simple - low-tech - method for coordinating file transfers between multiple remote hosts is to create and delete "marker files". Have you considered simply polling for marker files?

4) Try and do the most processing on the hosts with the best connectivity. For example, M2 and M1?

paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • I get it. What I was looking for was a way to maybe run an scp of the file, either from M1 or M2, to M1 and specify a port number using -P so that the specified port would automatically route to port 21 on M3. It leaves me with two problems: 1) How do I get the full blown FTP URL to be accepted? 2) How do I deal with the fact that FTP uses two ports? The marker file is ok, but I don't need it since the file transfer from M2 to M1 is known to be complete by the running script. – user680453 Apr 17 '12 at 19:45
0

You can use inotify to trigger ftp and cp.

check https://github.com/seb-m/pyinotify to add your hooks.

kofemann
  • 4,217
  • 1
  • 34
  • 39