diff options
author | thomascube <thomas@roundcube.net> | 2007-03-23 19:07:15 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2007-03-23 19:07:15 +0000 |
commit | 6d09984ea83861adb225a985b924eecb948702df (patch) | |
tree | 5fb3f6eac1d857d0b74420e1ad9d87d029ffbda2 /bin | |
parent | 28bfe4dc80a1431655666cfb3cec30f89e3459c7 (diff) |
Prompt for password in message import shell script
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/msgimport | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/bin/msgimport b/bin/msgimport index c8081e21a..f0ed3c046 100755 --- a/bin/msgimport +++ b/bin/msgimport @@ -42,25 +42,46 @@ function get_args($aliases=array()) } -// get arguments -$args = get_args(array('h' => 'host', 'u' => 'user', 'p' => 'pass', 'f' => 'file')); - -if (!($args['host'] && $args['user'] && $args['pass'] && $args['file'])) +function print_usage() { - print "Missing required parameters.\n"; - print "Usage: msgimport -h imap-host -u user-name -p password -f message-file\n"; + print "Usage: msgimport -h imap-host -u user-name -f message-file\n"; print "-host IMAP host\n"; print "-user IMAP user name\n"; - print "-pass IMAP password\n"; print "-file Message file to upload\n"; +} + + +// get arguments +$args = get_args(array('h' => 'host', 'u' => 'user', 'p' => 'pass', 'f' => 'file')) + array('host' => 'localhost'); + +if ($_SERVER['argv'][1] == 'help') +{ + print_usage(); + exit; +} +else if (!($args['host'] && $args['file'])) +{ + print "Missing required parameters.\n"; + print_usage(); exit; } else if (!is_file($args['file'])) { print "Cannot read message file\n"; - exit; + exit; +} + +// prompt for username if not set +if (empty($args['user'])) +{ + //fwrite(STDOUT, "Please enter your name\n"); + echo "IMAP user: "; + $args['user'] = trim(fgets(STDIN)); } +// prompt for password +echo "Password: "; +$args['pass'] = trim(fgets(STDIN)); // parse $host URL $a_host = parse_url($args['host']); |