tree /some/directory | print.sh
Is there any way for print.sh to know that "tree -f /some/directory" was called, without trying to parse
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
In general this information cannot be obtained.
print.sh can easily determine that its input is coming from a pipe, but not what is at the other end of the pipe. The first process may even have terminated, with its output fully contained in the pipe buffer. In this case, not even traversing the process list will give you any information.
Whatever it is you're trying to, you need to look for a solution in a different solution. This is probably going to involve having the script that's calling the pipe do the logging the first command.