Script redirect command output failed, why?

Hi, I put a for loop in a script to eject backup tapes from the robot. The command echo' output goes to the log file without problem, but command vmchange's output does not go to the log file although it's working fine. It still displays on the screen. I've tried '2>&1 1>$log', but nothing changed.

Why? It really bothers me. Please help. Thank you!

for tape in `/usr/openv/netbackup/bin/goodies/available_media | grep TLD | grep FULL | sort | awk '{print $1}'`
do
  echo "Eject $tape" >> /tmp/tapeject.log
  vmchange -res -multi_eject -w -verbose -rn 0 -rt tld -rh `hostname` -vh `hostname` -ml $tape -single_cycle >> /tmp/tapeject.log
done
# ./ejecttest
Slot# MediaID Barcode     MAP_Element#  Batch  Status
    6 000010  UNKNOWN                1      1  Ejected.
Moving media ID 000010 to standalone residence in the database.: Slot# MediaID Barcode     MAP_Element#  Batch  Status
    9 000012  UNKNOWN                2      1  Ejected.
Moving media ID 000012 to standalone residence in the database.: Slot# MediaID Barcode     MAP_Element#  Batch  Status
   10 000065  UNKNOWN                3      1  Ejected.
Moving media ID 000065 to standalone residence in the database.: Slot# MediaID Barcode     MAP_Element#  Batch  Status
   14 000066  UNKNOWN                4      1  Ejected.
Moving media ID 000066 to standalone residence in the database.: Slot# MediaID Barcode     MAP_Element#  Batch  Status
   16 000170  UNKNOWN                5      1  Ejected.
Moving media ID 000170 to standalone residence in the database.: Slot# MediaID Barcode     MAP_Element#  Batch  Status
    7 000177  UNKNOWN               -1     -1  Eject aborted.
Slot# MediaID Barcode     MAP_Element#  Batch  Status
    4 000179  UNKNOWN               -1     -1  Eject aborted.
Slot# MediaID Barcode     MAP_Element#  Batch  Status
   12 000518  UNKNOWN               -1     -1  Eject aborted.

perhaps you need to use undocumented parameter for vmchange:
"-sec 1"

Thank you for the reply. What is "-sec 1"?

Programs can bypass any redirection by opening /dev/tty and talking to you through that. This is how ssh and su can demand your password even when they're in the middle of a pipe chain. This is supposed to only be used for interaction with the user, but sometimes pops up when you don't want it, as you've seen.

1 Like

I have found it with google, and it has something to do with user interaction (which, presumably, is issue here):
Backup Central Forums :: View topic - Automating NBU ejects w/vmchange - Solaris

1 Like

Please accept my thanks.

I will try '-sec 1' tomorrow morning (if there are some FULL tapes that need to eject :))

---------- Post updated 10-05-11 at 12:17 PM ---------- Previous update was 10-04-11 at 05:54 PM ----------

'-sec 1' does not work.

Is there a way to disable or pass the interaction of the command?