Pexpect

Posted January 17

I need to have a script that automatically download a file via scp. The file to be downloaded  has current date on it and the script must download the file for the current date everyday.

At first I was using expect, but it won't work on cron(since it needs tty and cron doesn't run on tty). So I ended up using python's pexpect

The code goes like this:

#!/usr/bin/env python
import pexpect
import time
from datetime import date
today = date.today();

REMOTE_FILE="/root/backup/backup-%s.sql.gz" % (today.isoformat())
LOCAL_FILE="/root/dump_backup/."

USER="root"
HOST="192.168.10.1"
PASS="thiisisthepassword"
CMD="scp %s@%s:%s %s" % (USER, HOST, REMOTE_FILE, LOCAL_FILE)

child = pexpect.spawn(CMD, timeout=None)
child.expect('password:')
child.sendline(PASS)

Hope it can help someone.

Tags: python expect pexpect work | Comments (0) »

Get Unread Messages In Gmail's Inbox

Posted December 5

is:unread in:inbox

Comments (0) »

Google OpenID Error

Posted September 29


PHP Warning: openssl_verify() [function.openssl-verify]: supplied key param cannot be coerced into a public key in ~/Auth/OpenID/google_discovery.php on line 441
PHP Warning: openssl_pkey_free() expects parameter 1 to be resource, boolean given in ~/Auth/OpenID/google_discovery.php on line 443
PHP Fatal error: Error while attempting OpenID discovery: Signature verification failed. in ~/Auth/OpenID/google_discovery.php on line 101

Two days wasted on this. And I should've known that my machine was running PHP 5.1.6, upgraded to 5.2.17 and the messages disappeared.

Tags: work google openid | Comments (0) »

Still on Google Provisioning API - Move Users to Organization

Posted September 22

This guide:
Moving Users to an Organization Unit
Is not working.

Use this:
Updating an Organization User
For each users to be moved instead.

Dooh.

Tags: google provisioning API work | Comments (0) »

Google Provisioning API scope

Posted August 22

Sebelum ada update dari Google, untuk melakukan interaksi dengan Google Provisioning API dengan 3-legged OAuth cukup menggunakan

https://apps-apis.google.com/a/feeds/

Setelah ada update, scope nya di pecah2 jadi beberapa bagian:

Untuk mendapatkan customerId (yang dipake untuk operasi yang berkaitan dengan organization)

https://apps-apis.google.com/a/feeds/policies/

Untuk operasi yang berkaitan dengan group

https://apps-apis.google.com/a/feeds/groups/

Untuk operasi yang berkaitan dengan user

https://apps-apis.google.com/a/feeds/user/

Jadi kalo tiba2 ada aplikasi anda yang pake 3-legged OAuth dengan Google Provisioning API dan ada error "Token invalid - AuthSub token has wrong scope", mungkin itu gara2 imbas perubahan scope yang dipecah oleh Google.

In my case, I replaced the previous single scope with the 3 different new scopes, and it worked again.

Tags: google provisioning API authsub oauth scope | Comments (1) »