다음은 PIE 그래프를 작성하는 데 사용하는 쉘 스크립트입니다.sh -x 대 bash -x 쉘 스크립트 실행 중
#! /bin/bash
TEMP=$(mktemp -t chart.html)
QUERY1=36
QUERY2=64
cat > $TEMP <<EOF
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Title');
data.addColumn('number', 'Value');
data.addRows([
['Error Percentage', $QUERY1],
['No Error Percentage', $QUERY2]
]);
// Set chart options
var options = {'title':'Errors',
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>
EOF
# open browser
case $(uname) in
Darwin)
open -a /Applications/Google\ Chrome.app $TEMP
;;
Linux|SunOS)
firefox $TEMP
;;
esac
문제 설명 : -
내가 chart.sh
로 위의 파일을 저장. 그리고 내가 sh -x chart.sh
로 위의 chart.sh
파일을 실행하려고 할 때마다 나는 항상
syntax error at line number 3: `TEMP=$' unexpected
된 직후 오류를 얻을하지만 시스 - 위의 sh
파일을 실행하려고 할 때
bash -x chart.sh
그때 나는 어떤 error
도 얻지 않는다. 왜 그래야만하지? 내 셸 스크립트에 문제가 있습니까? 그리고 언제든지 sh -x chart.sh
처럼 실행해야한다면 쉘 스크립트에서 변경해야 할 사항이 있습니까?
나는 SunOS
을 실행 중입니다.
"sh"는 어떤 것을 실행하고 있습니까? 그리고 SunOS/Solaris의 버전은 무엇입니까? – Random832
SunOS의 버전 이름은 어떻게 찾을 수 있습니까? 내가 'uname-a' 할 때. bash-3.00 $ uname -a SunOS lvsaishdc3in0001 5.10 Generic_142901-02 i86pc i386 i86pc ' – AKIWEB
/bin/sh는 POSIX 호환되지 않습니다. – jordanm