Hi all,
I successfully managed to run a bash/CGI test script, but my main index.sh script won't execute because of the following error:
Code:
./index: 1: #!/bin/bash: not found
What are all those strange letters in front of /bin/bash?? Something wrong with the encoding?
This is a working CGI/bash script:
Code:
#!/bin/bash
WHO=`who | gawk '{print $1}'`
echo "Content-type: text/html"
echo ""
echo "<html>"
echo "<head>"
echo "<title>system information for $(hostname -s)</title>"
echo "</head>"
echo "<body>"
echo "<h2>General system information for host $(hostname -s)</h2>"
echo "<h3>Users logged on:</h3>"
echo "<p>$WHO</p>"
echo "<h3>System uptime:</h3>"
echo "<p>$(uptime)</p>"
echo "</body>"
echo "</html>"
Code:
laurent@server:/home/www/cgi-bin$ sudo ./sysinfo
Content-type: text/html
<html>
<head>
<title>system information for server</title>
</head>
<body>
<h2>General system information for host server</h2>
<h3>Users logged on:</h3>
<p>laurent
laurent</p>
<h3>System uptime:</h3>
<p> 15:08:43 up 7 days, 5:40, 2 users, load average: 1.67, 1.43, 1.26</p>
</body>
</html>
This doesn't work:
Code:
#!/bin/bash
UPTIME=`uptime`
HOST=`hostname -s`
echo 'Content-type: text/html'
echo ''
echo '<html xmlns="http://www.w3.org/1999/xhtml">'
echo '<head>'
echo '<meta name="keywords" content="" />'
echo '<meta name="description" content="" />'
echo '<title>Monitoring Center for $HOST | Overview</title>'
echo '<link href="http://fonts.googleapis.com/css?family=Arvo" rel="stylesheet" type="text/css" />'
echo '<link href="style.css" rel="stylesheet" type="text/css" media="screen" />'
echo '</head>'
etc ...
etc ...
Code:
laurent@server:/home/www/cgi-bin$ sudo ./index
./index: 1: #!/bin/bash: not found
Content-type: text/html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
etc ...
etc ...
Any advice? Thanks!