bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'exec' produced internal code output instead of normal


From: Dale R. Worley
Subject: Re: 'exec' produced internal code output instead of normal
Date: Sun, 14 Mar 2021 10:37:00 -0400

> 2021年3月13日(土) 8:06 Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>:
>> but using it resulted sometimes output of code of the script in the output
>> of the files
>> removing exec made it work normally as supposed

One possibility is a typo, using "<<" rather than "<".

Koichi Murase <myoga.murase@gmail.com> writes:
> I don't know about `socat', but maybe it's just the file descriptor
> collision. One needs to make sure that the file descriptor is not yet
> used when a new file descriptor is opened. For example, in Bash
> scripts, one should use the file descriptor 3--9 if you manually
> specify it because the file descriptors larger than 9 may be already
> used for other purposes.

bash has the useful ability to select an unused file descriptor, such as

    exec {new_descr}>wherever

That opens the file "wherever" for writing on some previously closed
file descriptor and assigns the number to the variable "new_descr".
After that you can do

   echo >&$new_descr

etc.

Dale



reply via email to

[Prev in Thread] Current Thread [Next in Thread]