-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmpw-cp
executable file
·94 lines (74 loc) · 2.99 KB
/
mpw-cp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python
# mpw-cp script for copying files.
import sys
import socket as s
import time
import os
if len(sys.argv)==1:
print """
mpw-cp usage:
./mpw-cp <source host>:<source file or dir> <destination host>:<destination file or dir> <number of streams> <pacing rate in MB> <tcp buffer in kB>
example for local cluster use with Gigabit Ethernet:
./mpw-cp machine-a:/home/you/yourfile him@machine-b:/home/him/yourfileinhishome 4 500 256
"""
sys.exit()
reverse_server = 0
# if reverse_server == 0 then the MPWide server will be placed on the destination host.
# if reverse_server == 1 then the MPWide server will be placed on the source host.
left_string = sys.argv[1]
right_string = sys.argv[2]
other_args=""
if len(sys.argv)>3:
for i in range(3,len(sys.argv)):
other_args += sys.argv[i]
other_args += " "
print other_args
cstrings = left_string.split(":",3)
sstrings = right_string.split(":",3)
# Filter out "'s:" prefix which denotes server location.
if cstrings[0] == "s":
reverse_server = 1
print "mpw-cp: Enabling REVERSE mode (server on source host)."
cstrings.pop(0)
if sstrings[0] == "s":
sstrings.pop(0)
leftside = cstrings
rightside = sstrings
if len(cstrings) == 1:
leftside = [s.gethostname(),cstrings[0]]
if len(sstrings) == 1:
rightside = [s.gethostname(),sstrings[0]]
scmd = ""
ccmd = ""
def url_filter(s):
t = s
if(t.find('@') >= 0):
s = s.split('@')
t = s[1]
return t
# server side
if len(sstrings) == 1:
scmd = "~/.mpwide/MPWFileCopy " + s.gethostbyname(url_filter(leftside[0])) + " 0 " + rightside[1] + " " + other_args + " > mpwide.log &"
scmdr = "~/.mpwide/MPWFileCopy " + s.gethostbyname(url_filter(leftside[0])) + " 0 " + rightside[1] + " " + other_args
if len(cstrings) == 1:
ccmd = "~/.mpwide/MPWFileCopy "+ s.gethostbyname(url_filter(rightside[0])) + " 1 " + leftside[1]+ " " + other_args + " "
ccmdr = "~/.mpwide/MPWFileCopy "+ s.gethostbyname(url_filter(rightside[0])) + " 1 " + leftside[1]+ " " + other_args + " > mpwide.log & "
if len(sstrings) == 2:
scmd = "ssh -f " + rightside[0] +" '~/.mpwide/MPWFileCopy "+ s.gethostbyname(url_filter(leftside[0]))+ " 0 "+ rightside[1]+ " "+ other_args +" > mpwide.log &'"
scmdr = "ssh " + rightside[0] +" '~/.mpwide/MPWFileCopy "+ s.gethostbyname(url_filter(leftside[0]))+ " 0 "+ rightside[1]+ " "+ other_args +"'"
if len(cstrings) == 2:
ccmd = "ssh "+ leftside[0]+ " '~/.mpwide/MPWFileCopy "+ s.gethostbyname(url_filter(rightside[0]))+ " 1 "+ leftside[1]+ " "+ other_args +" '"
ccmdr = "ssh -f "+ leftside[0]+ " '~/.mpwide/MPWFileCopy "+ s.gethostbyname(url_filter(rightside[0]))+ " 1 "+ leftside[1]+ " "+ other_args +" > mpwide.log &' "
print "mpw-cp: The client output will follow on screen:"
if reverse_server==0:
print "mpw-cp: Server command:", scmd
print "mpw-cp: Client command:", ccmd
os.system(scmd)
time.sleep(3.0)
os.system(ccmd)
else:
print "mpw-cp: Server command:", ccmdr
print "mpw-cp: Client command:", scmdr
os.system(ccmdr)
time.sleep(3.0)
os.system(scmdr)