LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   MEPIS (https://www.linuxquestions.org/questions/mepis-64/)
-   -   Twittering my System Status (https://www.linuxquestions.org/questions/mepis-64/twittering-my-system-status-711334/)

skyegod 03-13-2009 08:19 AM

Twittering my System Status
 
Good day all,

I am trying to get my system to twitter it's status to me.
I am just starting with system uptime at the moment, to try and get that working.

This is the script that I am using:
Code:

#!/bin/bash
curl -u username:password -d status=”$*” http://twitter.com/statuses/update.xml

Then I set a cron job

Code:

*/10 * * * * /bin/sh /path/to/your/twitter/script.sh My PC uptime is $(uptime)
Yet all I get is a bunch of
?My
and
My PC uptime is

For those that want to see the tweets - check out skyegod on twitter

This is where I got the source for this code from.

If somebody could help I would really appreciate it

BTW - running Mepis 8.

Thanks

David the H. 03-15-2009 12:34 AM

First of all, I don't think the /bin/sh is needed, because the first line in the script already calls /bin/bash to run itself.

Second, it seems like putting the sent data in the cronjob command itself is a rather sloppy way to go about it. Why not include the uptime information in the script itself instead? You can use the function syntax, which will make it easier to modify or add other information in the future the same way.

Code:

#!/bin/bash

function MYUPTIME {

echo "My PC uptime is: $(uptime)"

}

curl -u username:password -d status=$(MYUPTIME) http://twitter.com/statuses/update.xml

then your cronjob can be simply:

Code:

*/10 * * * * /path/to/your/twitter/script.sh

Edit: Come to think about it, the /bin/sh is probably there because it needs to run the $(uptime) command outside of the script. Moving uptime inside the script is what makes it unnecessary.

skyegod 03-16-2009 08:10 AM

Thank you -

I will give that a shot later when I get home.

Thanks again


All times are GMT -5. The time now is 05:18 AM.