-
Notifications
You must be signed in to change notification settings - Fork 10
/
mcgetms
executable file
·79 lines (69 loc) · 2.38 KB
/
mcgetms
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
#!/bin/tcsh -f
# Downloads a whole MONTH or a specifc MONTH/DAY of miniSEED data from
# a networked Nanometrics seismometer (our MC-PH1_0248...) storing
# them (as hourly files, however named) inside a directory YYYY/MM/DD.
#
# USAGE:
# MCGETMS YYYY MM, e.g.
# MCGETMS 2017 7
#
# MCGETMS YYYY MM DD, e.g.
# MCGETMS 2017 9 25, etc
#
# NOTES: Use -x to see what exactly gets expanded!
# Do not use leading 0... past 7 these are invalid octals!
#
# See also: MCMS2SAC (shell script)
# MCMS2MAT (MATLAB script)
#
# Last modified by jirving-at-princeton.edu, 09/12/2017
# Last modified by fjsimons-at-alum.mit.edu, 04/23/2020
set warnin = 0
if($#argv < 1)then
echo ' '
echo 'MCGETMS: At least two input argument expected:'
echo ' '
echo '----------> MCGETMS YYYY MM, e.g. MCGETMS 2017 7'
echo '----------> MCGETMS YYYY MM DD, e.g. MCGETMS 2017 9 25'
echo ' '
echo 'Do not use leading 0... past 7 these are invalid octals'
@ warnin +=1
goto label999
endif
# Where is the instrument reachable? Better ping it to be sure.
set IP = geo-mcph1-0248
# The environmental variable $MC needs to be set to a valid directory
test ! -d $MC && mkdir $MC
# Set this flag if you need to, which you probably do
set flag = "-o PubkeyAuthentication=no"
# Parameters of the "search" and making of target directories
set yr = $1
test ! -d $MC/$yr && mkdir $MC/$yr
set mo = `printf "%2.2i" $2`
test ! -d $MC/$yr/$mo && mkdir $MC/$yr/$mo
if ($# >2) then
# Downloading a specific day of a specific month
set dy = `printf "%2.2i" $3`
echo Recursively downloading $IP\:/media/removable0/$yr/$mo/$dy to $MC/$yr/$mo/$dy
scp -rp $flag $USER@$IP\:/media/removable0/$yr/$mo/$dy $MC/$yr/$mo
# Set the permissions to not very permissive
chmod 444 $MC/$yr/$mo/$dy/*
chmod 555 $MC/$yr/$mo/$dy/soh
chmod 444 $MC/$yr/$mo/$dy/soh/*
else
# Downloading a whole month
echo Recursively downloading $IP\:/media/removable0/$yr/$mo to $MC/$yr/$mo
scp -rp $flag $USER@$IP\:/media/removable0/$yr/$mo $MC/$yr
# Set the permissions to not very permissive
chmod 444 $MC/$yr/$mo/*/*
chmod 555 $MC/$yr/$mo/*/soh
chmod 444 $MC/$yr/$mo/*/soh/*
endif
label999:
echo ' '
if ($warnin == 1) then
echo "Script MCGETMS stopped, $warnin warning message generated"
else
echo "Script MCGETMS stopped, $warnin warning messages generated"
endif
echo ' '