[PLUG] trying to see the redirects for an active command question

Reid nrwahl at protonmail.com
Mon Aug 26 23:21:20 UTC 2019


https://gist.github.com/davejamesmiller/1966557

Something like this ought to work, if this is what you're trying to do. Example in bash.

[reid at laptop ~]$ cat /tmp/tmp.sh
#!/bin/bash

real_stdin=$(readlink /proc/$$/fd/0);
real_stdout=$(readlink /proc/$$/fd/1);

echo $real_stdin
echo $real_stdout

[reid at laptop ~]$ /tmp/tmp.sh < /etc/services
/etc/services
/dev/pts/7



Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, August 26, 2019 3:43 PM, logical american <website.reader3 at gmail.com> wrote:

> Hi:
>
> Does anyone know how to view the redirected input and output for a
> running command from the /proc section ?
>
> Yes I am aware of /proc/pid/fd/0,1,2 being input/output/error but
> reading the man page for /proc showed only the cmdline and args[1], but
> I could not see how to obtain the redirect information sent to the std
> input and output for the CLI command, at the beginning of command execution.
>
> example:
>
> % my_command < input.file > output.file
>
> /proc/pid/fd/0 and /proc/pid/fd/1 show nothing about the redirect,
> however I want to recover that information for the running command.
>
> Thanks for figuring this out.
>
> -   Randall
>
>     [1] http://man7.org/linux/man-pages/man5/proc.5.html
>
>
> PLUG mailing list
> PLUG at pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug





More information about the PLUG mailing list