Active Topics

 



Notices


Reply
Thread Tools
Posts: 9 | Thanked: 1 time | Joined on Mar 2010
#221
Using the option --spider prevents you from having to actually download content, you only need the response code.
 
Posts: 48 | Thanked: 5 times | Joined on Mar 2010
#222
Hi !

I am a newbie for this DCEW, just playing with it since few days, reading its wiki pages and this forum regularly. I got lost as for me for certain reasons, scripts i could found on wiki or even the built in ones not working or better to say, several of them not working.

E.g. I would like to create a battery indicator as follows :

Battery : 45% (445mAh / 1200mAh) - Charging

"- Charging" part ONLY if charging

This should be simple as this script should do the main part (except the "- Charging") :

hal-device bme | awk '/l.p/ {perc = $3}; /g.c/ {curr = $3}; /g.la/ {last = $3}; /s_c/ {isch = $3} END if (isch == "false") {print perc" % ("curr"/"last" mAh)"} else {print "Charging"}'


Problem is, that it does not show the full capacity (1200mAh) for some reason.

I had found an other script where they used something like "grep" and that one could read out the 1200mAh, but I could not combine the 2 as I did not understood the structure how it works as lack of experience.

The other thing is, I tried to create a command retrieves the actual IP address which the device reachable from :

echo WAN IP: `wget -q -O - api.myiptest.com | awk -F"\"" '{print $4" ("$12" @ "$20", "toupper($28)")"}'`; echo LAN IP: `/sbin/ifconfig | awk '/Bc/ {print $2}' | cut -c6-`

Problem is, while my device connected to my home router, lcoal ip shown, but when the device conencted to my Mobile Internet , no ip shows at all, and none of the cases shows any country or such. However, if I load e.g. ipchicken.com, logically, I can see my public ip even through the firewall.

Could someone help me to go through these 2 examples to make it udnerstandable how tehy work, so i can learn it and create other scripts pelase ?

I know I am sking a lot, btu hoping someone could spare a bit of time,

Many Thansk in advance,

Andrew
 
Posts: 539 | Thanked: 165 times | Joined on Feb 2010 @ Berlin, Germany
#223
Originally Posted by orac View Post
Which is why I am interested in the status response and why I started with if you can.
No, you said, you'd recommend this way. Everybody can use the IP of the server where the site is hosted, but not for everyone this makes sense.
 
Posts: 156 | Thanked: 90 times | Joined on Jan 2010
#224
coolice: Ok, let's go through your questions...

First of all, everything built-in and in wiki is TESTED and it WORKS. So that means that problems are on your side.

First script that you ask for is the one you pasted and is the same as in wiki. It does EXACTLY what you want. It shows percentage, current mAh, last full mAh (after a reboot last full mAh becomes 0 because the phone forgets the value, but everything else works) and when the phone is charging, it displays "Charging".

The other one you found (using grep) reads design mAh, which is always the same. Last full mAh used in the script using awk is better, because you can also monitor battery wear level with it, but it displays 0 value between a reboot and next charging.

About the IP script: The script you found displays wlan0 LAN ip and WAN IP as seen from the internet. The gprs0's IP which you can get with ifconfig is often from private address range, because mobile operators like to use NAT, so this method is not reliable and therefore not used.

Go to myiptest.com from N900's browser while connected to GPRS and post the results here. Maybe myiptest.com doesn't recognize your IP yet.
 
Posts: 9 | Thanked: 1 time | Joined on Mar 2010
#225
Originally Posted by x-lette View Post
No, you said, you'd recommend this way. Everybody can use the IP of the server where the site is hosted, but not for everyone this makes sense.
Actually, the question is not trivial.

To start with, we are in agreement, but you seem to misunderstand the following:

If you can, I would recommend using the IP...

There is an implication by stating "If you can" that what follows will not be suitable for all cases. Of course it is true that for all cases an IP can be used to just test the server and it goes without saying that it can be done.

What cannot be done by using the IP is as you stated, when using name based virtual hosting - which is why I refer to the status response as being important, since my script will give a different error response for the following conditions:

1. server cannot be resolved, server is down or server is up, but nothing from the appropriate port.
2. conditions which may indicate a running server but no website. maybe your account has been blocked returning a file not found.

I am with Bluehost and there 2 things I will note here, 1, I will need to modify the script further to get the result because they will block your account by simply placing a different .htaccess file in your folder if there is a potential cross site script problem with any php they know of as a security risk. updating the php code will have the site unblocked.

2. It costs an extra dollar a month to have your own IP. I can operate personal services on incoming ports.

This script will pause the entire desktop whilst running, so avoiding a name lookup is quite appropriate, an alternative solution is add your host to the /etc/resolv.conf and this will allow name based hosts to be checked more quickly.

I tried to make my solution as generic as possible, so only people who know about virtual hosts would know what they need to use. Those who don't know may or may not care that its just the physical server that is being checked and therefore may prefer the speed of an IP check

For those who know what they are looking for, they can of course modify this or write their own.

I thought your original comment was useful, to help clarify.

Neither of us was wrong though.

orac.
 
Posts: 9 | Thanked: 1 time | Joined on Jan 2010
#226
actually i have to use the dns names because i have internal ip's when im at work on the wlan and external ip's when im outside work. however i am ALWAYS working.
 
Posts: 9 | Thanked: 1 time | Joined on Mar 2010
#227
Originally Posted by TheSov View Post
actually i have to use the dns names because i have internal ip's when im at work on the wlan and external ip's when im outside work. however i am ALWAYS working.
That make sense. At my work, our public servers are offsite so our office has no public facing presence nor a public domain.

I only need to check public facing servers.

orac
 
Posts: 66 | Thanked: 9 times | Joined on Mar 2010 @ Netherlands
#228
could someone help me with a command?

I would like a command that shows the full date. preferably in this format:
<day nr (1-31)>-<month name><monthnumber>-<year>

with those i should be able to mod it if i want it changed.
 
Posts: 10 | Thanked: 5 times | Joined on Jan 2010 @ Tasmania, Australia
#229
Originally Posted by GrimmReaperNL View Post
could someone help me with a command?

I would like a command that shows the full date. preferably in this format:
<day nr (1-31)>-<month name><monthnumber>-<year>

with those i should be able to mod it if i want it changed.
date +%d-%B%m-%Y

Basically it's date +<format string>. For more info on format string possibilities see http://unixhelp.ed.ac.uk/CGI/man-cgi?date.
 

The Following User Says Thank You to mjec For This Useful Post:
Posts: 66 | Thanked: 9 times | Joined on Mar 2010 @ Netherlands
#230
Originally Posted by mjec View Post
date +%d-%B%m-%Y

Basically it's date +<format string>. For more info on format string possibilities see http://unixhelp.ed.ac.uk/CGI/man-cgi?date.
sweet, thanks.

edit: for other users. make sure you disable updating or it'll drain your battery. or so it did for me

Last edited by GrimmReaperNL; 2010-04-01 at 21:02.
 
Reply


 
Forum Jump


All times are GMT. The time now is 07:51.