Re: [bash] [redirection] appending using a file descriptor
From: claudibus (sick_soul_at_yahoo.it)
Date: 09/29/03
- Next message: Stephane CHAZELAS: "Re: Where can I get the source code for the Bourne Shell?"
- Previous message: Ian Fitchet: "Re: Need help with sed syntax"
- In reply to: Stephane CHAZELAS: "Re: [bash] [redirection] appending using a file descriptor"
- Next in thread: Stephane CHAZELAS: "Re: [bash] [redirection] appending using a file descriptor"
- Reply: Stephane CHAZELAS: "Re: [bash] [redirection] appending using a file descriptor"
- Reply: Kenny McCormack: "Re: [bash] [redirection] appending using a file descriptor"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Sep 2003 02:41:29 -0700
> claudibus wrote:
> > I'm trying to append data to a file in bash using only an already open
> > file descriptor.
> >
> > example (supposing file descriptor 5 is already open)
> >
> > cat FILE >&5
> >
> > works ok, but overwrites the file instead of just appending. So I
> > guessed
> [...]
>
> That's « exec 5> some-file » that overwrites the file (at this
> stage it truncates it to zero size).
>
> Change it to « exec 5>> some-file ».
[cut]
No, the point is I don't have the filename of the target. I have the
shell opened as a child process of a program, having the file
descriptor n corresponding to target file already open for writing.
Now I would like the stdout of the shell redirected to file descriptor
n in append mode, NOT the file descriptor n redirected in append mode
to some-filename.
/* code example starts */
extern char* qs; /* a temporary string buffer */
void printheader(FILE* target) {
fd = fileno(target);
sprintf(qs, "date -I >&%i", fd); /* this is ok, but overwrites.
*/
system(qs); /* would like to append instead
*/
}
/* code example ends */
Claudio
- Next message: Stephane CHAZELAS: "Re: Where can I get the source code for the Bourne Shell?"
- Previous message: Ian Fitchet: "Re: Need help with sed syntax"
- In reply to: Stephane CHAZELAS: "Re: [bash] [redirection] appending using a file descriptor"
- Next in thread: Stephane CHAZELAS: "Re: [bash] [redirection] appending using a file descriptor"
- Reply: Stephane CHAZELAS: "Re: [bash] [redirection] appending using a file descriptor"
- Reply: Kenny McCormack: "Re: [bash] [redirection] appending using a file descriptor"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]