[rt-users] Prompting for password from RT CLI

Karger, Amir Amir_Karger at hms.harvard.edu
Wed May 30 10:36:22 EDT 2012


Let's say I make a wrapper that runs an rt command-line command and pipes it to another command. For example,  "rtmy" does:

rt ls -i "Owner='$USER' and Status != 'resolved'" | rt show - -f id,subject,requestors,status

I prefer not to put my password in ~/.rtrc. So if I don't have a ~/.rt_sessions (or the session expired), then rt prints "Password:" to stdout. But if I'm piping to another command, then my piped command just hangs. And since "Password:" is being printed to stdout and not stderr, I don't even see the prompt!

One fix is:

1) Copy the rt executable and make rt_with_flush by adding $|=1 near the top of the file

2) Write a little Perl script, rt_password_check.pl that reads the first 9 characters from stdin, and passes it along to the user if they were "Password:" (and handles bad password etc. gracefully)

3) Change each wrapper script so that BEFORE doing whatever it's designed to do, it does a very quick RT command (like "rt show -f id ticket/1") and pipes it to rt_password_check.pl. If the simple command is successful, it does what the user actually wanted.

Of course, this is kind of annoying. Has anyone else encountered this before?  Do you know a simpler way to fix it?

Thanks,

-Amir Karger



More information about the rt-users mailing list