I have a equipment (a scale) on my small Network that displays the weight on any browser, any computer as I type “[url=http://Http://169.254.79.250/MostraPeso.shtm]Http://169.254.79.250/MostraPeso.shtm[/url]” as the url.
I am trying to create an Apple script to write a log file cotaining returned data and time, etc…
I can’t begin my script because I am stuck on this:
This is my whole script at this moment. After I can get it to work, I will continue writting it.
Here at my work I have 3 computer on the LAN and 1 is a Mac with Apache enabled. If I change the URL on the script, pointing it to the Mac with Apache running, the script works.
But it won’t work with the web server in the scale I am trying to access.
On the terminal of Mac OS X (10.2.8) I type the curl -a comand and get a result. But the script fails…
Can’t understand why…
I apreciate any help. May be I should try a diferente aproach to the problem of getting the source code from the Web Server running on the scale.
If I do a script just like you replied I get the same error message mentioned before. I tried it. But what puzzzles me is that the same comand on the Terminal displays the souce code of the page! The error only happens within Applescript!
May be it happens because of a special characther not suported by Applescript? Can you see a “?” character on the code?
The scale is not a computer. It has a special card built inside that enables it to be connected to the LAN, and “serve” a site from where I can see the weight on the scale and do some configuration of the equipment.
In our country, we don’t use pounds for measuring weight. We use Kilograms. So the weight displayed on the scale at the moment I captured the source code I posted in this topic was “0,0 Kg”. Please note the weight on the souce code.
I intend to write an Applescript that will capture the html code, filter the value just before “Kg”, check if it is diferent than zero or diferent than the previous value and write a text log like this:
On February 4th at 13:13 hrs the weight changed to 1234,0 Kg.
On February 4th at 13:45 hrs the weight changed to 2638,0 Kg.
On February 4th at 13:58 hrs the weight changed to 875,0 Kg.
On February 4th at 14:23 hrs the weight changed to 234,0 Kg.
I think I should take a diferent approach to the problem. But have no idea how.
It is a good idea trying. I am at home right now. I will try it tomorow morning.
My scale can weight up to 3.500,0 Kg (in Brazil we use comas for decimals and periods for thousands), so I believe I will need to capture the seven characteres before “Kg”…
I tryed this on the Terminal:
It works if I paste the code on the terminal and hit return twice very quickly.
I ran across a book called “Wicked Cool Shell Scripts” today, and one of the examples is exactly what you need!!
I am using BBedit, but you can use any text editor, as long as it uses unix return characters in the file. If you are not sure you can also copy the script and then, in the terminal, do ‘pbpaste > cleaner.script’ which will paste the text into a new file. Then go to the file’s directory and do ‘chmod +x cleaner.script’ to make it executable.
#!/bin/sh
Original is from the book “Wicked Cool Shell Scripts” by No Starch Press.
To test it, in the terminal, do ‘./cleaner.script | less’ while in the same directory as the script.
Now for the easy part, the beginning of your Applescript:
set result_items to {“”}
– change the line below to where your script is. Use the full path!
set feedback to do shell script “/Users/davidr/Desktop/temp/cleaner.shellscript”
– paragraph 5 is the line after “Peso Atual (PESO ESTVEL):”
set item 1 of result_items to paragraph 5 of feedback
display dialog feedback
Am I ever glad I found that shell script! It looks very useful for a whole bunch of other scripts…
Now what?
dAVE … who learned a whole bunch of new things today!
A few quick questions… how often do you wnat the script to run? Do you want to use text-edit plus, or would you prefer to write the data straigh to a text file? if the result is " 0,0kg" do you want to put it in the file or skip it until there is data?