Operating System - Linux
1752710 Members
5885 Online
108789 Solutions
New Discussion юеВ

Re: Output redirection help in ksh script

 
SOLVED
Go to solution
Rodney Hills
Honored Contributor

Re: Output redirection help in ksh script

Are those curly brackets you are using?

If so then the syntax requires a ; before the closing right curly bracket.

HTH

-- Rod Hills
There be dragons...
Mike Smith_33
Super Advisor

Re: Output redirection help in ksh script

This one didn't work either but I am confused as to why, it made sense.

{ fbackup $backup_type -u $verbose_option $nfs_option -g $graph_file $index_opt
} $logfile 2>&1


+ fbackup -0 -u -n -g /bow/bowgraph -I /bow/backuplogs/25Apr06.full -c /bow/backup_config -d /bow/fbackupfiles/dates -f /dev/rmt/0m
fbackup(1004): session begins on Tue Apr 25 15:18:36 2006
fbackup(3203): volume 1 has been used 10 time(s)
fbackup(3024): writing volume 1 to the output file /dev/rmt/0m
fbackup(1102): WARNING: unable to stat file /entsys/tmp/cos.003354981498422125.1385.6
fbackup(3005): WARNING: file number 33092 was NOT backed up
fbackup(1030): warnings encountered during backup
fbackup(3055): total file blocks read for backup: 21283397
fbackup(3056): total blocks written to output file /dev/rmt/0m: 21851691
James R. Ferguson
Acclaimed Contributor

Re: Output redirection help in ksh script

Hi (again) Mike:

As Rodney noted, a a final semicolon is required after the last statement in curly braces. I agree that you last post seems correct otherwise. That aside, I use this in one of my scripts:

# ( /usr/sbin/fbackup -f $FB_DEV -0 -u -v -g $FB_GRF -V $FB_VOL -c $FB_CNF 2>&1 ; echo $? > $FB_XIT ) | tee -ia $FB_LOG

The approach I that I took here uses a sub process (and yes, there is not a semicolon in this syntax) but writes STDOUT and STDERR to ${FB_LOG} as well as the terminal.

Regards!

...JRF...

Mike Smith_33
Super Advisor

Re: Output redirection help in ksh script

I have added the semi colon before the right bracket and still the output comes to the screen. From what I understand of the output and error redirection this should work

1>$logfile 2>&1

This fbackup command is inside a script and I am trying to save the output and/or error/warnings in the $logfile. I am apparently not seeing what is wrong with the syntax.
Christian Tremblay
Trusted Contributor

Re: Output redirection help in ksh script

shouldn't your redirection line be:

2>&1 >> $logfile
Mike Smith_33
Super Advisor

Re: Output redirection help in ksh script

Some of the earlier answers were correct, it was my mistake in that I should have been using $log_file instead of $logfile. I would have found the answer much sooner.

Thanks for all the help and for putting up with my typo.