Register
It is currently Thu Oct 23, 2014 11:49 am

Status change


All times are UTC - 6 hours


Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2
Author Message
 PostPosted: Sun May 30, 2010 1:56 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
curl -u ... -d status="Server $actualStatus" http://...


Top
 Profile  
 PostPosted: Sun May 30, 2010 2:15 pm   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
Watael you a top man mate =D> send me your paypal address and have a drink on me

I added the date/time to the status update as otherwise twitter rejects it

Code:
log=$( date '+%d/%m/%Y %H:%M:%S' )

then curl -u user:password -d status="Server $actualStatus $log" http://twitter.com/statuses/update.xml


However when the status changes the time stays the same as before?

# Server On 30/05/2010 21:07:06 less than 20 seconds ago via API

* Delete

#

Server Off 30/05/2010 21:07:06 2 minutes ago via API

* Delete

#

Server On 30/05/2010 21:06:09 2 minutes ago via API

* Delete

#

Server Off 30/05/2010 21:06:09 3 minutes ago via API


Last edited by BrianUK on Sun May 30, 2010 3:49 pm, edited 1 time in total.

Top
 Profile  
 PostPosted: Sun May 30, 2010 2:38 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
did you leave your real username and password?

if log assigment is inside the while loop this is not a bash problem, but a Twitter one.
it should be
Code:
   if [ "$actualStatus" != "$previousStatus" ]
   then log=$(date...)
          curl ...


Top
 Profile  
 PostPosted: Sun May 30, 2010 3:51 pm   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
no :-/

thanks i'll have a 'bash' tomorrow.


Top
 Profile  
 PostPosted: Tue Jun 01, 2010 3:28 am   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
i've tried

Code:
   trip=$( date '+%d/%m/%Y %H:%M:%S' )
   then curl -u username:password -d status="Server $actualStatus $trip" http://twitter.com/statuses/update.xml


however it update twitter constantly not only on status change

Server On 01/06/2010 10:26:13 less than 5 seconds ago via API
Server On 01/06/2010 10:26:12 less than 10 seconds ago via API
Server On 01/06/2010 10:26:10 less than 10 seconds ago via API
Server Off 01/06/2010 10:26:08 less than 10 seconds ago via API
Server Off 01/06/2010 10:26:06 less than 20 seconds ago via API
Server Off 01/06/2010 10:26:04 less than 20 seconds ago via API
Server Off 01/06/2010 10:26:02 less than 20 seconds ago via API


Top
 Profile  
 PostPosted: Tue Jun 01, 2010 6:31 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
that's what I tried to warn you:
Code:
unset var
if [ -z "$var" ]
Date=$(date)
then echo "do smth"
fi
do smth
unset var
if [ -n "$var" ]
Date=$(date)
then echo "do smth"
fi
do smth
what ever var exists or not, if echoes "do smth"; but
Code:
unset var
if [ -n "$var" ]
then Date=$(date)
     echo "do smth"
fi
here, if var doesn't exist, if does not echo !

I have some feelings about what happens, but not enough to tell exactly the reason for such a behaviour :(


Top
 Profile  
 PostPosted: Wed Jun 02, 2010 2:09 pm   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
now i'm really confused :-/


Top
 Profile  
 PostPosted: Wed Jun 02, 2010 6:16 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
I don't care too much about 5$ reward, just don't pretend the script is yours!


Last edited by Watael on Thu Jun 03, 2010 3:20 pm, edited 1 time in total.

Top
 Profile  
 PostPosted: Thu Jun 03, 2010 10:15 am   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
Watael wrote:
Code:
if [ -z "$var" ]
Date=$(date)
then echo "do smth"
fi

Why does the assignment precede then?


Last edited by choroba on Tue Jun 08, 2010 3:01 pm, edited 1 time in total.

Top
 Profile  
 PostPosted: Tue Jun 08, 2010 3:55 am   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
where does

Code:
    unset var
    if [ -n "$var" ]
    then Date=$(date)
         echo "do smth"
    fi


need to go in the script then?


Top
 Profile  
 PostPosted: Tue Jun 08, 2010 5:12 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
=)) nowhere, it was just an example.
in your case, it's about the trip's assignment that needs to be after then
:)


Top
 Profile  
 PostPosted: Tue Jun 08, 2010 7:29 am   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
ha ha =)) it's ok i've sorted it now :)


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP