The Following 2 Users Say Thank You to TiagoTiago For This Useful Post: | ||
|
2010-12-29
, 01:24
|
Posts: 17 |
Thanked: 17 times |
Joined on Aug 2008
@ Portsmouth UK
|
#22
|
#!/usr/bin/perl $arg = shift(@ARGV); if(!$arg){ $data = `gconftool-2 --all-dirs /apps/modest/accounts`; @accounts = split(/\n/, $data); print "\nPlease choose an account from the following list:\n"; print "(alternatively, pass an account name from below as a parameter to toggle it)\n\n"; for($i = 0; $i < ($#accounts + 1); $i++){ $thisAccount = $accounts[$i]; ($name) = $thisAccount =~ /accounts\/(.+?)ID/; $status = `gconftool-2 -g $thisAccount/enabled`; if($status =~ /true/i){ $currentState = "enabled"; } elsif($status =~ /false/i){ $currentState = "disabled"; } else{ $currentState = "state unknown"; } print "\t[".$i."] ".$name.": ".$currentState."\n"; } print "\nSelection [0-".($i - 1)." or [q]uit]: "; $id = <STDIN>; if($id =~ /^q/i){ exit(0); } print "\n"; if($id !~ /^\d+$/ || !$accounts[$id]){ print "Invalid selection.\n"; exit(1); } $path = $accounts[$id]; chomp($path); }else{ $path = "/apps/modest/accounts/".$arg."ID"; } $status = `gconftool-2 -g $path/enabled`; if($status =~ /true/i){ system("gconftool-2 -s ".$path."/enabled --type bool false"); if($? > 0){ print "The account could not be disabled.\n"; exit($?); } print "The account has been disabled.\n"; exit(0); }elsif($status =~ /false/i){ system("gconftool-2 -s ".$path."/enabled --type bool true"); if($? > 0){ print "The account could not be enabled.\n"; exit($?); } print "The account has been enabled.\n"; exit(0); }else{ print "The specified account could not be found.\n"; exit(1); }
~ $ perl modest-account.pl Please choose an account from the following list: (alternatively, pass an account name from below as a parameter to toggle it) [0] Home: enabled [1] Mail@32@for@32@Exchange: enabled [2] Work: enabled Selection [0-2 or [q]uit]: 1 The account has been disabled. ~ $ perl modest-account.pl Home The account has been disabled. ~ $ perl modest-account.pl Home The account has been enabled. ~ $
The Following User Says Thank You to cmantito For This Useful Post: | ||
|
2010-12-30
, 02:16
|
Posts: 17 |
Thanked: 17 times |
Joined on Aug 2008
@ Portsmouth UK
|
#23
|
#!/usr/bin/python import sys import commands import string try: arg = sys.argv[1] path = "/apps/modest/accounts/" + arg + "ID" except: print "\nPlease choose an account from the following list:" print "(alternatively, pass an account name from below as a parameter to toggle it)\n" data = commands.getoutput("gconftool-2 --all-dirs /apps/modest/accounts") accounts = string.split(data, '\n') i = 0 for acct in accounts: # path: /apps/modest/accounts/xxxID pathParts = string.split(acct, '/') theId = pathParts[4] # theId = xxxID nameParts = string.split(theId, 'ID') # ['xxx', ''] name = nameParts[0] status = commands.getoutput("gconftool-2 -g " + acct + "/enabled") if status == "true": statusText = "enabled" elif status == "false": statusText = "disabled" else: statusText = "state unknown" print "[" + str(i) + "] " + name + ": " + statusText i = i + 1 try: id = int(raw_input("\n\tSelection [0-" + str(i) + "]: ")) if id > i: print "Invalid selection." sys.exit(1) if id < 0: print "Invalid selection." sys.exit(1) except: sys.exit(0) path = accounts[id] path = string.rstrip(path) status = commands.getoutput("gconftool-2 -g " + path + "/enabled") if status == "true": exitState = commands.getstatusoutput("gconftool-2 -s " + path + "/enabled --type bool false") if exitState[0] > 0: print "The account could not be disabled." sys.exit(exitState) print "The account has been disabled." sys.exit(0) elif status == "false": exitState = commands.getstatusoutput("gconftool-2 -s " + path + "/enabled --type bool true") if exitState[0] > 0: print "The account could not be enabled." sys.exit(exitState) print "The account has been enabled." sys.exit(0) else: print "The specified account could not be found." sys.exit(1)
The Following User Says Thank You to cmantito For This Useful Post: | ||
Tags |
email, modest, privacy, wanking |
|
NOKIA N900: IT'S OVER NINE THOUSAND
How to use HotspotShield in the N900
Google Voice from outside the US + Free international calls: LEARN HOW HERE!!!
Last edited by TiagoTiago; 2010-12-28 at 07:11.