LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > MEPIS
User Name
Password
MEPIS This forum is for the discussion of MEPIS Linux.

Notices


Reply
  Search this Thread
Old 03-13-2009, 08:19 AM   #1
skyegod
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Rep: Reputation: 0
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
 
Old 03-15-2009, 12:34 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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.

Last edited by David the H.; 03-15-2009 at 12:42 AM.
 
Old 03-16-2009, 08:10 AM   #3
skyegod
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you -

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

Thanks again
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Twittering from the Command Line LXer Syndicated Linux News 0 05-22-2008 01:50 AM
Status of system, which commands decribes it the best ? sarajevo Linux - Server 2 08-08-2007 07:04 AM
Exit status of system command?? rmvinodh123 Programming 4 05-04-2007 11:15 AM
System status bar? mikegorb Linux - Software 4 12-13-2004 10:46 AM
System Status Spyiish Slackware 6 10-30-2004 02:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > MEPIS

All times are GMT -5. The time now is 05:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration