0

我正在尝试构建一个 Bash CGI 脚本,该脚本将坐标作为来自 url 的参数,并使用 osmosis 来提取地图,并使用拆分器和 mkgmap 来制作地图,以便可以使用 Qlandkarte 打开它。我的问题是,当我输入 wget localhost/cgi-bin/script.pl?top=42&left=10&bottom=39&right=9&file=map.osm 时,linux终端会读取带有坐标的文件。我怎样才能让 wget 只激活脚本,以便它获取坐标并执行命令。而且当最后创建地图时,如何返回由脚本创建的文件。谢谢

#!/bin/bash

TOP=`echo "$QUERY_STRING" | grep -oE "(^|[?&])top=[0.0-9.0]+" | cut -f 2 -d "=" | head -n1`
LEFT=`echo "$QUERY_STRING" | grep -oE "(^|[?&])left=[0.0-9.0]+" | cut -f 2 -d "=" | head -n1`
BOTTOM=`echo "$QUERY_STRING" | grep -oE "(^|[?&])bottom=[0.0-9.0]+" | cut -f 2 -d "=" | head -n1`
RIGHT=`echo "$QUERY_STRING" | grep -oE "(^|[?&])right=[0.0-9.0]+" | cut -f 2 -d "=" | head -n1`
FILE=`echo "$QUERY_STRING" | grep -oE "(^|[?&])file=[^&]+" | sed "s/%20/ /g" | cut -f 2 -d "="`

$(sudo osmosis --read-xml file=bulgaria.osm --bounding-box top=$TOP left=$LEFT bottom=$BOTTOM right=$RIGHT --write-xml file=$FILE)
$(sudo java -Xmx900m -jar splitter.jar --max-nodes=110000 $FILE)
$(sudo java -ea -Xmx900m -jar mkgmap.jar --tdbfile --route -c template.args)

echo "Content-type: text/html"
echo ""
4

0 回答 0