Script redirect command output failed, why?


 
Thread Tools Search this Thread
Operating Systems Solaris Script redirect command output failed, why?
# 1  
Old 10-03-2011
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!

Code:
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

Code:
# ./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.


Last edited by Scott; 10-03-2011 at 10:42 AM.. Reason: Use CODE TAGS for code and terminal output
# 2  
Old 10-03-2011
perhaps you need to use undocumented parameter for vmchange:
"-sec 1"
# 3  
Old 10-03-2011
Quote:
Originally Posted by orange47
perhaps you need to use undocumented parameter for vmchange:
"-sec 1"
Thank you for the reply. What is "-sec 1"?
# 4  
Old 10-03-2011
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.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 10-04-2011
Quote:
Originally Posted by aixlover
Thank you for the reply. What is "-sec 1"?
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
This User Gave Thanks to orange47 For This Post:
# 6  
Old 10-05-2011
Please accept my thanks.

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

---------- 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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies

2. Shell Programming and Scripting

Redirect output of command line to for loop

I would like to redirect output of command line in for loop as $line. Output should be processed as line but instead it throw whole output. Could somebody help me on how to redirect output of command line and process it line by line without sending output to any file. below is my code ... (1 Reply)
Discussion started by: tapia
1 Replies

3. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

4. AIX

Not able to redirect output of command

Hi All,. We are using AIX as the OS to host the Oracle ERP. We have a command FNDLOAD which is used to load setups. When this command is run, it outputs names of log files and any errors to the screen. I am trying to redirect this output to a file because we have large number of these... (4 Replies)
Discussion started by: mansmaan
4 Replies

5. Shell Programming and Scripting

how to Redirect the output of telnet command on a terminal to a file ?

(/home/user1)-> more script.sh #!/bin/ksh ( echo open devicename sleep 3; echo user; sleep 2; echo password; sleep 2; echo "/info/dump"; ---------> This needs to redirect to a file .Can be number of pages sleep 2; echo "exit" ) | telnet Please use code tags next time for... (2 Replies)
Discussion started by: necro98
2 Replies

6. UNIX and Linux Applications

How to redirect grep command output to same file

Hi Everyone, Can anyone please tell me, how can I redirect the grep command output to same file. I am trying with below command but my original file contains no data after executing the command. $grep pattern file1 > file1 Kind Regards, Eswar (5 Replies)
Discussion started by: picheswa
5 Replies

7. Programming

How to Run a Linux Command and Redirect its output to a socket in C

I have a Linux socket server program. I need to run the commands sent by the client and return the output to client. Is there a quicker way? I tried with ptr=popen(command, "r"); and then fgets(buf, size,ptr); write buf to socket fgets hangs for me. Now, I would like to know if I can... (3 Replies)
Discussion started by: rajeshomallur
3 Replies

8. Shell Programming and Scripting

how to redirect the output of a grep command to a file inside a shell script

hi, i wat to get the output of a grep command in a file. but when i am trying out the same grep command in the unix prompt its working fine.. i am getting the output properly.. but when i am writing the same command inside my shell script , its just creating a new output file with no contents... (11 Replies)
Discussion started by: kripssmart
11 Replies

9. Shell Programming and Scripting

redirect output of dos2unix command

hi I want to suppress the output of dos2unix command in my shell script. I'm using follwing command in my script dos2unix somefile >/dev/null But it's still showing output while executing the script.Please help me to sort this out Thanks (4 Replies)
Discussion started by: nrbhole
4 Replies

10. UNIX for Dummies Questions & Answers

redirect command output to variable

Hi, I am looking for a way to redirect the result from a command into a variable. This is the scenario. Using the find command I will be getting multiple records/lines back. Here is the command I am using: find /”path”/ -name nohup.out -print This now is giving me the paths and file... (1 Reply)
Discussion started by: hugow
1 Replies
Login or Register to Ask a Question