How can I setup a read/write device that spawns a program?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
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.
linux shell devices fifo
add a comment |Â
up vote
0
down vote
favorite
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.
linux shell devices fifo
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
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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.
linux shell devices fifo
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.
linux shell devices fifo
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
add a comment |Â
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
add a comment |Â
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
.
add a comment |Â
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
.
add a comment |Â
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
.
add a comment |Â
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
.
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
.
answered Oct 22 '17 at 1:14
Sukima
20618
20618
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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