You are not logged in.

#1 2025-12-06 10:31:23

system72
Member
Registered: 2025-11-22
Posts: 338
Website

[solved]reading from stdin

hi im working on a script that uploads stuff to my site, i was wondering how i could read from stdin e.g.:

wl-copy "aa"
wl-paste | script

here is my script https://git.system72.dev/dotfiles/tree/.local/bin/store

be patient with me pls i am a shell scripting n00b

Last edited by system72 (2025-12-06 11:31:37)

Offline

#2 2025-12-06 10:41:22

mpan
Member
Registered: 2012-08-01
Posts: 1,536
Website

Re: [solved]reading from stdin

For example by marking stdin input with the lack of filename argument or it being set to ‘-’ (a single dash). This is a pretty common way.


Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#3 2025-12-06 10:44:17

system72
Member
Registered: 2025-11-22
Posts: 338
Website

Re: [solved]reading from stdin

mpan wrote:

For example by marking stdin input with the lack of filename argument or it being set to ‘-’ (a single dash). This is a pretty common way.

can you show me an example of how it would be implemented

Offline

#4 2025-12-06 11:16:02

mpan
Member
Registered: 2012-08-01
Posts: 1,536
Website

Re: [solved]reading from stdin

Implementing which part is a problem? You already know `if`.


Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#5 2025-12-06 11:17:35

system72
Member
Registered: 2025-11-22
Posts: 338
Website

Re: [solved]reading from stdin

idk how to read from stdin

Offline

#6 2025-12-06 11:28:26

mpan
Member
Registered: 2012-08-01
Posts: 1,536
Website

Re: [solved]reading from stdin

`cat` without arguments reads from stdin. You may redirect output to to a file:

cat >file

Then you can rsync the file to the server.

One can’t directly rsync from stdin. The tool is designed to work with actual files in storage. It’s possible to coerce rsync into accepting data from stdin, but AFAIK there is no way to reliably make it not getting grumpy about that.


Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#7 2025-12-06 11:31:19

system72
Member
Registered: 2025-11-22
Posts: 338
Website

Re: [solved]reading from stdin

ok ty this seems to work..

Offline

Board footer

Powered by FluxBB