LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-24-2011, 12:54 PM   #1
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
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
 
Old 04-24-2011, 01:54 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
Old 04-24-2011, 02:04 PM   #3
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Original Poster
Rep: Reputation: 36
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.

Last edited by kdelover; 04-24-2011 at 02:08 PM.
 
Old 04-24-2011, 02:36 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
If you can send data into a pipe, you can send it to a file. Almost zero difference.
--- rod.
 
Old 04-24-2011, 04:09 PM   #5
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Original Poster
Rep: Reputation: 36
Yes,you are right.May be i should get rid of a named pipe and use a text file instead. Thanks for the help.
 
Old 04-24-2011, 04:20 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
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.

Last edited by jschiwal; 04-24-2011 at 04:23 PM.
 
  


Reply


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
pipe output to append to a text file davee Linux - Newbie 5 03-22-2016 08:44 PM
Opening a File by using a named pipe akm3 Programming 1 02-17-2009 06:04 AM
text match pipe to file then delete from original text file create new dir automatic tr1px Linux - Newbie 6 09-10-2008 10:40 PM
Which light text editor can copy text from file and paste in browser? davidas Linux - Software 9 03-06-2006 12:28 PM
Pipe telnet session output to text file joshlamerritt Linux - Software 3 02-10-2004 09:42 PM


All times are GMT -5. The time now is 06:22 AM.

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