Changeset 210 for client/trunk/bin
- Timestamp:
- 12/28/10 18:44:52 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/trunk/bin/sophie
r187 r210 7 7 use Pod::Usage; 8 8 use Config::General; 9 use File::Temp; 9 10 10 11 GetOptions( … … 16 17 'd=s' => \my @options, 17 18 'daemon' => \my $daemon, 19 20 # Command option: 21 'set-password=s' => \my $password, 22 'edit-var=s' => \my $data, 18 23 ) or pod2usage; 19 24 … … 34 39 } 35 40 41 my $sc = Sophie::Client->new( 42 server => $url, 43 login => $login, 44 password => $pass, 45 type => $type, 46 ); 47 48 if ($password) { 49 my $res = $sc->send_request('user.set_password', $password); 50 if (ref $res && !$res->is_fault) { 51 print $res->value . "\n"; 52 exit(0); 53 } else { 54 print( (ref $res ? $res->string : $res) . "\n"); 55 exit(1); 56 } 57 } elsif ($data) { 58 my $res = $sc->send_request('user.dumpdata', $data); 59 if (ref $res && !$res->is_fault) { 60 my $tmp = File::Temp->new(); 61 print $tmp $res->value . "\n"; 62 close($tmp); 63 system($ENV{EDITOR} || 'vi', $tmp->filename); 64 if (open(my $fh, '<', $tmp->filename)) { 65 my $string = join('', <$fh>); 66 close($fh); 67 unlink($tmp->filename); 68 my $res2 = $sc->send_request('user.loaddata', $data, $string); 69 if (ref $res2 && !$res2->is_fault) { 70 print $res2->value . "\n"; 71 exit(0); 72 } else { 73 print( (ref $res2 ? $res2->string : $res2) . "\n"); 74 exit(1); 75 } 76 } 77 } else { 78 print( (ref $res ? $res->string : $res) . "\n"); 79 exit(1); 80 } 81 } 82 36 83 if ($daemon) { 37 84 my $pid = fork(); … … 47 94 } 48 95 49 my $sc = Sophie::Client->new(50 server => $url,51 login => $login,52 password => $pass,53 type => $type,54 );55 56 96 $sc->run;
Note: See TracChangeset
for help on using the changeset viewer.