-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetshapeandzip.sh
More file actions
70 lines (59 loc) · 1.73 KB
/
getshapeandzip.sh
File metadata and controls
70 lines (59 loc) · 1.73 KB
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
#!/bin/bash
#!/usr/bin/expect
#######################################################
## Shapefile Zipper
## Created by Dale Kunce: (dale@normalhabit.com)
##
## This script will work for any shapefile directory,
## just modify the variables below.
##
#######################################################
date=%Y-%m-%d
datadir=dir1
filehome=dir2/path/to/file
destination1=hostname:final/destination1/
destination2=hostname:final/destination2/
filesource=hostname/path/to/shapefile
user=user
password=password
#######################################################
## Do Not Edit Below this line
#######################################################
cd $datadir
wget -r -l1 --no-parent -A.shp $filesource
wget -r -l1 --no-parent -A.shx $filesource
wget -r -l1 --no-parent -A.prj $filesource
wget -r -l1 --no-parent -A.dbf $filesource
cd $filehome
for f in *.shp
do
filename=${f%.*}
datefile=${f%.*}.txt
stat -c %Y $filename.shp | echo "$f last updated on $filedate." > $datefile
echo "For more information please contact" >> $datefile
zip $filename.zip $filename.*
echo "created $crsname zipfile"
expect -c "
# exp_internal 1 # uncomment for debugging
spawn scp $filehome/$filename.zip $user@$destination2
expect {
"*password:*" { send $password\r\n; interact }
eof { exit }
}
exit
"
done
for f in *.shp
do
filename=${f%.*}
expect -c "
# exp_internal 1 # uncomment for debugging
spawn scp $filehome/$filename.shp $filehome/$filename.shx $filehome/$filename.prj $filehome/$filename.dbf $user@$destination1
expect {
"*password:*" { send $password\r\n; interact }
eof { exit }
}
exit
"
done
echo "zipper complete"