I'm using a basic bash script to generate an HTML page. It's just using echo, since only one thing needs to change. That one thing is a variable $extip, which = my current IP.
I've used this technique a bunch of times and it's worked just fine, but now I have a strange problem. Here's the pertinent script:
#!/bin/bash
#
extip="`/sbin/ifconfig eth1 | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`"
echo "<HTML>"
echo "<HEAD>"
echo "<TITLE>n8shome</TITLE>"
echo '<SCRIPT LANGUAGE="JavaScript"><-- setTimeout ("changePage()", 3000); function changePage() { if (self.parent.frames.length != 0) self.parent.location="http://'$extip'"; }//--></SCRIPT>'
echo "</HEAD>"
Now when I run this shell script, the HTML comes out just fine except for one thing. Notice the JavaScript line in the code above, specifically the $extip variable. Now here's how that same line comes out:
<SCRIPT LANGUAGE="JavaScript">
<!--
setTimeout ("changePage()", 0)
function changePage() {
if (self.parent.frames.length != 0)
self.parent.location="http://xxx.xxx.xxx.xxx^M/cam/index.html";
}
//-->
</SCRIPT>
For some reason, suddenly I have an extra ^M behind the IP. It screws up the function of the script itself. I'm stumped. I tried to keep everything simple so as to avoid strange errors, but that's exactly what I got. Although I can appreciate true irony, I'd much rather see it in a Greek tragedy than in my code.
Details:
Mandrake 7.2
Bash shell
x86 platform
AMD K6/380
Again, I'm currently using the exact same technique for importing my current IP in about 6 different scripts, four of which are generating HTML the same way. It only goofs up when I try to echo it out while inside that JavaScript line. *shrug*
Thanks in advance, even if you can't make a suggestion I appreciate you reading this long message.
nathan
I've used this technique a bunch of times and it's worked just fine, but now I have a strange problem. Here's the pertinent script:
#!/bin/bash
#
extip="`/sbin/ifconfig eth1 | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`"
echo "<HTML>"
echo "<HEAD>"
echo "<TITLE>n8shome</TITLE>"
echo '<SCRIPT LANGUAGE="JavaScript"><-- setTimeout ("changePage()", 3000); function changePage() { if (self.parent.frames.length != 0) self.parent.location="http://'$extip'"; }//--></SCRIPT>'
echo "</HEAD>"
Now when I run this shell script, the HTML comes out just fine except for one thing. Notice the JavaScript line in the code above, specifically the $extip variable. Now here's how that same line comes out:
<SCRIPT LANGUAGE="JavaScript">
<!--
setTimeout ("changePage()", 0)
function changePage() {
if (self.parent.frames.length != 0)
self.parent.location="http://xxx.xxx.xxx.xxx^M/cam/index.html";
}
//-->
</SCRIPT>
For some reason, suddenly I have an extra ^M behind the IP. It screws up the function of the script itself. I'm stumped. I tried to keep everything simple so as to avoid strange errors, but that's exactly what I got. Although I can appreciate true irony, I'd much rather see it in a Greek tragedy than in my code.
Details:
Mandrake 7.2
Bash shell
x86 platform
AMD K6/380
Again, I'm currently using the exact same technique for importing my current IP in about 6 different scripts, four of which are generating HTML the same way. It only goofs up when I try to echo it out while inside that JavaScript line. *shrug*
Thanks in advance, even if you can't make a suggestion I appreciate you reading this long message.
nathan