Help! Need to write my first script

Hi Folks!

I am a MacUser and am trying to learn Unix for the last few months.

I will explain in detail what I am trying to do, and apreciate you help if you can teach me even if it is a single comand line inside the script.

I own a small company, where I manufacture special gypsums and plasters for dental use. Outside my office, I have a equipment, a scale, that can weigh pallets from 0 to 3000Kg. This scale is connected to my small network and has its own web server.

If I type on this URL: http://169.254.79.250/peso.html on any web browser, on any computer, on my small network, a request is sent to the webserver installed on my scale and a page as this is displayed:

example in .html: Click here for example.

(this example contains a Javascript that will direct you to an error page after a few seconds. You might need to click on the "back" button of your browser)

example of the source code in pdf: click here for example in pdf

One can notice inside the code where it is written "0,0Kg". This is the variable. As one of my employees places a new pallet with a diferent new weight this value changes.

OK!

This is what I want to do:

I want to write a script to run on the Macs's Unix terminal and do this:

1) Capture the html source code on http://169.254.79.250/peso.html (this is a reference in my small network)

2) Identify the variable inside the code, let's say each 10 seconds. (the value just before Kg)

3) Use a logical function to determine if the value has changed, and if it did change , write a line in a text file. (pesolog.txt)

Example of pesolog.txt:

O January 2nd 2004 at 12:45 peso has changed to 1254Kg
On January 2nd 2004 at 13:15 peso has changed to 1869kg
etc...

I thank you for your help, even if it is just a single command line.

Greeting from
Bernardo H�hl
Rio de Janeiro - Brazil

PS: This site is so CPU intensive on my Mac. My computer runs very, very slow when I have this page running.. Do you experience the same problem?

Go to user panel (User CP) and change the theme to another one. Seems like "InfoPop" is the most lightweight one.

hi,
wouldnt it be easier to write the LogFile from the website?

with html, php, javascript or whatever works?

Lazzar

Dear Lazzar,

We have to keep in mind that we need to capture code from a WebServer that has no hardisk or I have access to changing the way it works.

Let's assume that whatever I build, I will build on my computer.

Question 1) Can Javascript capture code on the remote WebServer and write it on my harddisk?

Question 2) Can PHP do just the same?

Could you give an example of how it can be done?

Thanks for your comments!

Bernardo H�hl

aww sorry i can't, it was just a wild guess :slight_smile:

Lazzar

Hi folks!

I have been able to display the souce code by typing the following:

telnet 169.254.79.250 80
GET /MostraPeso.shtm HTTP/1.0
User-Agent: Mozilla/1.1N (Macintosh; I; 68K)
Accept: */*

It works. I get the source code displayed on my terminal.

But when I write the shell script with these comands, only the first comand is executed. The next lines are only executed once the conection has been closed.

I think some lines are missing on the shell script to make it executable within the conection.

Please help!

Thanks!