Amir_Karger at hms
May 30, 2012, 7:36 AM
Post #1 of 1
Let's say I make a wrapper that runs an rt command-line command and pipes it to another command. For example, "rtmy" does:
Prompting for password from RT CLI
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?