LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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, 09: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, 01:34 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950
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 01:42 AM.
 
Old 03-16-2009, 09: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 02:50 AM
Status of system, which commands decribes it the best ? sarajevo Linux - Server 2 08-08-2007 08:04 AM
Exit status of system command?? rmvinodh123 Programming 4 05-04-2007 12:15 PM
System status bar? mikegorb Linux - Software 4 12-13-2004 11:46 AM
System Status Spyiish Slackware 6 10-30-2004 03:00 AM


All times are GMT -5. The time now is 01:03 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration