Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with pipe

Status
Not open for further replies.

vascobrito

Technical User
Feb 27, 2003
28
PT
hi there
problably this isn't the forum for my question but i'm geting desperated.

i'm trying this:

gbak -b -v mydb.gdb 2> | split -b -a2 mydb.bak 300m

this isn't working because it outputs the backup to a file named split instead of output to the command that splits the backup files. I have noticed that i can't use stdout in my HP-UX, there is no such device. How can i make this work?

any help , please?

thanks in advance
 
using a pipe will automatically redirect the stdout to the stdin of the next command in the pipe, you dont need the '2>' part unless you want to send the error messages also to the next command. i dont think you want the error messages from gbak to go to the split command. so simply remove the '2>' part. if you want to save the error messages (instead of getting them on to the terminal), you can use something like '2>gbak.err' instead of the '2>'.

so its either
gbak -b -v mydb.gdb | split -b -a2 mydb.bak 300m
or
gbak -b -v mydb.gdb 2>gbak.err | split -b -a2 mydb.bak 300m

--
ranga
 
thanks ranga
the problem is that i allready tryed that.
it simply gives me an error because gbak needs input file and output file. So, i have to indicate the standard output as a file. Another problem is that my HP-UX doesn't have the device /dev/stdout and i don't know how to create it or even if i can create it. Then i'm not sure how pipe works, does it wait for the first command to complete before it starts the other command, or the second command interacts with the stdout from the first command? If the second command only starts after the first is finished, then this doesn't matter because it will allways fill a 2,1gb file and colapse. But if the second interacts with the first, then i just have to find the way of indicating correctly the stdout of my system to the command.
i'm realy climbing the walls over this
thanks
 
well i dont know how to create /dev/stdout and i dont know anything about gbak either.there may be some option that would make it output to stdout (perhaps if you specify the output file as '-' ?). assuming there is no such way, here is something you can try.

create a FIFO (say in /tmp). use that as the output file for the gbak command (run in the background). then use the FIFO as the input for the split command. assuming that the second argument will be taken as the output file by gbak, here is what the commands will look like:

mkfifo /tmp/fifo ;
gbak -b -v mydb.gdb /tmp/fifo &
split -b -a2 - 300m < /tmp/fifo ;
(split -b -a2 /tmp/fifo 300m ;)
rm /tmp/fifo

about the shell pipe '|' : i think it does wait for the first command to finish before starting the second one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top