Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 04-26-2013, 09:03 PM   #1
Registered: Mar 2009
Posts: 51

Rep: Reputation: 10
Process IO redirection

I want to make is so that any process run in the current shell, if it tries to access (read/write) a certain filesystem path, it will get redirected to somewhere else. So for example:

$ bash
$ redirect /this/path/to /that/path
$ nano /this/path/to/textfile
So running the above (nano /this/path/to/textfile) would actually make nano open up a new file (or already existing one) at /that/path/textfile.

I have been researching this for awhile now and can't figure it out.
I am pretty sure there is a technical term for this (other than IO redirection which usually just give results for 'echo hi > file' on Google).

Any help is greatly appreciated.
Old 04-26-2013, 09:18 PM   #2
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian except for netbook still on Slackware 13.37 (and I have to support Ubuntu)
Posts: 8,572
Blog Entries: 30

Rep: Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182
Make /this/path/to a symlink to /that/path or another hardlink to the same file as /that/path?
Old 04-26-2013, 09:25 PM   #3
Registered: Mar 2009
Posts: 51

Original Poster
Rep: Reputation: 10
Yes I want basically that, but I want it to only be for the current shell. Everything else would still write to the path /this/path/to.
Old 04-27-2013, 02:14 PM   #4
Senior Member
Registered: Jan 2011
Location: Yawnstown, Ohio
Distribution: This is my kung.fu
Posts: 4,390
Blog Entries: 4

Rep: Reputation: Disabled
bash -r
Old 04-29-2013, 03:08 PM   #5
Registered: Mar 2009
Posts: 51

Original Poster
Rep: Reputation: 10
How would I do this with bash -r?

Chroot looked promising, but it has to be done as... root and it makes everything else disappear to the program.
Old 04-29-2013, 03:40 PM   #6
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 3,102

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
In the base setup, you can't.

The current process uses the kernels context of the user environment - and that is started at the login.

File paths are strictly global. The only "process" reference is the "current working directory".

Now environment variables can be set up... but the process has to know how to use them (most don't). The most frequently used of these is PATH, LD_LIBRARY_PATH, LD_PRELOAD - which are interpreted by a runtime library (PATH), or the process loader (result of exec system call).

What you are asking for is additional complexity in the runtime library - (as in how should it identify when something is redirected and when it isn't).

Symbolic links are global, not process specific. Plan 9 has some of this - but it is still very heavy handed about it (bind mounts are part, but bind mounts are also global unless you have created/activated namespaces for a process...)
Old 05-03-2013, 04:35 PM   #7
Registered: Mar 2009
Posts: 51

Original Poster
Rep: Reputation: 10
Ok, well thanks for the info.


filesystem, process, transparent

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script: stdin redirection + multiple curl process issues fernandomm Programming 1 07-04-2010 08:10 AM
Question in process redirection syfung Programming 1 09-20-2008 06:56 PM
Newbie on forking child process and I/O redirection neo_in_matrix Programming 4 09-16-2005 03:05 AM
redirection the process stdout do1do Linux - Security 3 11-23-2003 11:39 PM
redirection process stdout do1do Linux - General 2 11-23-2003 09:06 PM

All times are GMT -5. The time now is 07:04 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration