LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   feed text to a file editor from a named pipe (https://www.linuxquestions.org/questions/linux-newbie-8/feed-text-to-a-file-editor-from-a-named-pipe-876805/)

kdelover 04-24-2011 11:54 AM

feed text to a file editor from a named pipe
 
Hi Guys,

Does any one know how can i input text by reading from a named pipe to any popular GUI based text editor?

what i am doing is

Quote:

echo " hello world" > mypipe
(where mypipe is a named pipe)

and i want to do

Quote:

gedit < mypipe
at this instance gedit should open with the text hello world in it.

I am able to do
Quote:

gvim - < mypipe
,but this causes gvim to run in background waiting for input from STDIN.

Thanks

theNbomr 04-24-2011 12:54 PM

If all you want to do is get the editor started with a skeleton file, then why not just create the file, and start the editor with the file as a commandline argument?
Any method you come up with to provide the interactive input to the text editor from some source of your own contrivance will inevitably end up the way you've encountered with gvim. The editor, no matter what it is, is reading a single input source. When you replace that source with something you create, the editor cannot know when it should start reading elsewhere.
--- rod.

kdelover 04-24-2011 01:04 PM

HiNbomr,

I am doing some stuff in my perl script,and the output is sent to a named pipe,the script later is supposed to do an exec("file editor") and display the contents read from named pipe to the user.since the o/p is not fixed,i cant use a skeleton file for this.

theNbomr 04-24-2011 01:36 PM

If you can send data into a pipe, you can send it to a file. Almost zero difference.
--- rod.

kdelover 04-24-2011 03:09 PM

Yes,you are right.May be i should get rid of a named pipe and use a text file instead. Thanks for the help.

jschiwal 04-24-2011 03:20 PM

In the bash shell:
$EDITOR <(cat fifoname)

The user would have to "save as".

Seems like an odd way of doing it. Consider creating the file on the fly with a HERE document, using variables for values you had prompted the user for.


All times are GMT -5. The time now is 06:03 PM.