0

I am trying to hit a PHP url and post some information about my linux box using a cron job and wget.

*/30 * * * * wget -O /dev/null http://ping.xxx.com/xxx/up.php?mac=`ifconfig eth1 | awk '/HWaddr/ { print $5 }`\&uptime=`uptime`\&ip=`ifconfig eth1 | awk '/inet addr:/ {sub(/addr:/, "", $2); print $2 }`;

on php side i am tryint to get request parameters like mac, uptime and ip but i am only able to record mac. Reason i think is because uptime command has 23:42:10 up 22 min, load average: 0.00, 0.01, 0.04 as output which may be breaking the wget process. I am getting following message when i run wget

wget: not an http or ftp url: 23:42:10

Can someone please tell me how to pass parameters correctly?

Sachin
  • 119
  • 2
  • 19

3 Answers3

0

Try it this way:

*/30 * * * * wget -O http://ping.xxx.com/xxx/up.php?mac=`ifconfig eth1 | awk '/HWaddr/ { print $5 }`\&uptime=`uptime`\&ip=`ifconfig eth1 | awk '/inet addr:/ {sub(/addr:/, "", $2); print $2 }` /dev/null;

You are putting /dev/null where wget expects the url, you just have to switch /dev/null and the url

CodeBird
  • 3,883
  • 2
  • 20
  • 35
0

You can get the uptime in seconds from /proc/uptime:

cut -d " " -f 1 /proc/uptime

Geoff
  • 2,461
  • 2
  • 24
  • 42
0
 ?mac=`ifconfig eth1 | awk '/HWaddr/ { print $5 }`
\&uptime=`uptime`
\&ip=`ifconfig eth1 | awk '/inet addr:/ {sub(/addr:/, "", $2); print $2 }`;

Add quotes
                                                 V
 ?mac=`ifconfig eth1 | awk '/HWaddr/ { print $5 }'`
\&uptime=`uptime`
\&ip=`ifconfig eth1 | awk '/inet addr:/ {sub(/addr:/, "", $2); print $2 }'`;
                                                                         ^
user32
  • 177
  • 1
  • 2