How can I setup a read/write device that spawns a program?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite
1












I don't know if this is possible but I had no idea how to research this concept. Is it possible and if how do I...



create a device file (i.e. /dev/remoteclip) that will, when written to or read from, spawn a program or shell script?



The use case would be in sharing text to a remote clipboard. For example saw I have a Mac to the side of my Linux box. As it stands I can do the following to share content:



$ ssh macbox "pbcopy" < myFile
$ ssh macbox "pbpaste" > myFile


I am wondering if it is possible to have a device or FIFO on the linux filesystem that when you write to it it would execute the ssh command:



$ cat myFile >> /dev/macbook-clipboard
$ cat /dev/macbook-clipboard > myFile


That way editors and other programs can simply write to a device / FIFO.



This is more of a learning exercise on if this is possible and if so how. It is not a need and likely the merits of this is purely academic then useful in typical workflows.







share|improve this question
















  • 1




    This looks like a job for FUSE. Hopefully someone will be able to post an answer detailing how to get started.
    – dhag
    Oct 21 '17 at 17:09














up vote
0
down vote

favorite
1












I don't know if this is possible but I had no idea how to research this concept. Is it possible and if how do I...



create a device file (i.e. /dev/remoteclip) that will, when written to or read from, spawn a program or shell script?



The use case would be in sharing text to a remote clipboard. For example saw I have a Mac to the side of my Linux box. As it stands I can do the following to share content:



$ ssh macbox "pbcopy" < myFile
$ ssh macbox "pbpaste" > myFile


I am wondering if it is possible to have a device or FIFO on the linux filesystem that when you write to it it would execute the ssh command:



$ cat myFile >> /dev/macbook-clipboard
$ cat /dev/macbook-clipboard > myFile


That way editors and other programs can simply write to a device / FIFO.



This is more of a learning exercise on if this is possible and if so how. It is not a need and likely the merits of this is purely academic then useful in typical workflows.







share|improve this question
















  • 1




    This looks like a job for FUSE. Hopefully someone will be able to post an answer detailing how to get started.
    – dhag
    Oct 21 '17 at 17:09












up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





I don't know if this is possible but I had no idea how to research this concept. Is it possible and if how do I...



create a device file (i.e. /dev/remoteclip) that will, when written to or read from, spawn a program or shell script?



The use case would be in sharing text to a remote clipboard. For example saw I have a Mac to the side of my Linux box. As it stands I can do the following to share content:



$ ssh macbox "pbcopy" < myFile
$ ssh macbox "pbpaste" > myFile


I am wondering if it is possible to have a device or FIFO on the linux filesystem that when you write to it it would execute the ssh command:



$ cat myFile >> /dev/macbook-clipboard
$ cat /dev/macbook-clipboard > myFile


That way editors and other programs can simply write to a device / FIFO.



This is more of a learning exercise on if this is possible and if so how. It is not a need and likely the merits of this is purely academic then useful in typical workflows.







share|improve this question












I don't know if this is possible but I had no idea how to research this concept. Is it possible and if how do I...



create a device file (i.e. /dev/remoteclip) that will, when written to or read from, spawn a program or shell script?



The use case would be in sharing text to a remote clipboard. For example saw I have a Mac to the side of my Linux box. As it stands I can do the following to share content:



$ ssh macbox "pbcopy" < myFile
$ ssh macbox "pbpaste" > myFile


I am wondering if it is possible to have a device or FIFO on the linux filesystem that when you write to it it would execute the ssh command:



$ cat myFile >> /dev/macbook-clipboard
$ cat /dev/macbook-clipboard > myFile


That way editors and other programs can simply write to a device / FIFO.



This is more of a learning exercise on if this is possible and if so how. It is not a need and likely the merits of this is purely academic then useful in typical workflows.









share|improve this question











share|improve this question




share|improve this question










asked Oct 21 '17 at 16:43









Sukima

20618




20618







  • 1




    This looks like a job for FUSE. Hopefully someone will be able to post an answer detailing how to get started.
    – dhag
    Oct 21 '17 at 17:09












  • 1




    This looks like a job for FUSE. Hopefully someone will be able to post an answer detailing how to get started.
    – dhag
    Oct 21 '17 at 17:09







1




1




This looks like a job for FUSE. Hopefully someone will be able to post an answer detailing how to get started.
– dhag
Oct 21 '17 at 17:09




This looks like a job for FUSE. Hopefully someone will be able to post an answer detailing how to get started.
– dhag
Oct 21 '17 at 17:09










1 Answer
1






active

oldest

votes

















up vote
0
down vote













I found a way to accomplish this. It requires creating a background process that continues to read from the FIFO. For example:



$ mkfifo hopper
$ while :; do ssh macbox "pbcopy"; done < hopper &
$ cat myFile >> hopper


(Thanks to this SO answer)



Now I don't fully understand this but I'm willing to guess that having the < hopper on the surrounding while loop blocks the loop which is why the CPU doesn't appear to fry an egg and when no data is being funneled into the FIFO there isn't a stray SSH session sitting around.



I'm quite impressed with how thoughtful and forward thinking all these *Unix tools are. I honestly do not understand why this is taught in school or why modern software development is all about reinventing these age old wheels. Amazing!




To end the above process use kill %1.






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f399576%2fhow-can-i-setup-a-read-write-device-that-spawns-a-program%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    I found a way to accomplish this. It requires creating a background process that continues to read from the FIFO. For example:



    $ mkfifo hopper
    $ while :; do ssh macbox "pbcopy"; done < hopper &
    $ cat myFile >> hopper


    (Thanks to this SO answer)



    Now I don't fully understand this but I'm willing to guess that having the < hopper on the surrounding while loop blocks the loop which is why the CPU doesn't appear to fry an egg and when no data is being funneled into the FIFO there isn't a stray SSH session sitting around.



    I'm quite impressed with how thoughtful and forward thinking all these *Unix tools are. I honestly do not understand why this is taught in school or why modern software development is all about reinventing these age old wheels. Amazing!




    To end the above process use kill %1.






    share|improve this answer
























      up vote
      0
      down vote













      I found a way to accomplish this. It requires creating a background process that continues to read from the FIFO. For example:



      $ mkfifo hopper
      $ while :; do ssh macbox "pbcopy"; done < hopper &
      $ cat myFile >> hopper


      (Thanks to this SO answer)



      Now I don't fully understand this but I'm willing to guess that having the < hopper on the surrounding while loop blocks the loop which is why the CPU doesn't appear to fry an egg and when no data is being funneled into the FIFO there isn't a stray SSH session sitting around.



      I'm quite impressed with how thoughtful and forward thinking all these *Unix tools are. I honestly do not understand why this is taught in school or why modern software development is all about reinventing these age old wheels. Amazing!




      To end the above process use kill %1.






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        I found a way to accomplish this. It requires creating a background process that continues to read from the FIFO. For example:



        $ mkfifo hopper
        $ while :; do ssh macbox "pbcopy"; done < hopper &
        $ cat myFile >> hopper


        (Thanks to this SO answer)



        Now I don't fully understand this but I'm willing to guess that having the < hopper on the surrounding while loop blocks the loop which is why the CPU doesn't appear to fry an egg and when no data is being funneled into the FIFO there isn't a stray SSH session sitting around.



        I'm quite impressed with how thoughtful and forward thinking all these *Unix tools are. I honestly do not understand why this is taught in school or why modern software development is all about reinventing these age old wheels. Amazing!




        To end the above process use kill %1.






        share|improve this answer












        I found a way to accomplish this. It requires creating a background process that continues to read from the FIFO. For example:



        $ mkfifo hopper
        $ while :; do ssh macbox "pbcopy"; done < hopper &
        $ cat myFile >> hopper


        (Thanks to this SO answer)



        Now I don't fully understand this but I'm willing to guess that having the < hopper on the surrounding while loop blocks the loop which is why the CPU doesn't appear to fry an egg and when no data is being funneled into the FIFO there isn't a stray SSH session sitting around.



        I'm quite impressed with how thoughtful and forward thinking all these *Unix tools are. I honestly do not understand why this is taught in school or why modern software development is all about reinventing these age old wheels. Amazing!




        To end the above process use kill %1.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 22 '17 at 1:14









        Sukima

        20618




        20618



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f399576%2fhow-can-i-setup-a-read-write-device-that-spawns-a-program%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay