ptpb / pb

pb is a formerly-lightweight pastebin and url shortener
Other
549 stars 52 forks source link

how to add the command executed in the paste #242

Closed g4570n closed 5 years ago

g4570n commented 5 years ago

For example, if I execute the following:

uname -s | curl -F c=@- https://ptpb.pw/

the content of the paste will be:

Linux

How can I get the paste to contain the command used + the result, something like this:

$ uname -s
Linux
buhman commented 5 years ago

Not sure if I understand.

you mean like this?:

$ uname -s | tee >(curl -F c=@- https://ptpb.pw)
Linux
date: 2015-03-05T13:00:31.248000+00:00
digest: cd4bf5db2601ec9075425102d2b12a9ee5413d4a
long: AM1L9dsmAeyQdUJRAtKxKp7lQT1K
short: QT1K
size: 6
status: already exists
url: https://ptpb.pw/QT1K
glensc commented 5 years ago

@buhman he wants first line of paste to be command he executed on pipe. i don't think there's good way to do that without extra script.

buhman commented 5 years ago

first line of paste to be command he executed on pipe

$ bash -xc "uname -s" |& curl -F c=@- https://ptpb.pw/
date: 2019-01-07T01:41:25.538891+00:00
digest: fd7589f1613ca881061dfe6a5f2722c0c3894085
long: AP11ifFhPKiBBh3-al8nIsDDiUCF
short: iUCF
size: 17
status: created
url: https://ptpb.pw/iUCF
uuid: f3ffde45-c452-4ddf-bb12-c8540744a2c2
$ curl https://ptpb.pw/iUCF
+ uname -s
Linux
g4570n commented 5 years ago

Thanks @buhman , something like that was what I was referring to, similar to what it does: wgetpaste -c

glensc commented 5 years ago

the example should be added to docs as well: https://ptpb.pw/

is there an example that doesn't involve shell-quoting?

glensc commented 5 years ago

and the example doesn't work with bash3

➔ bash -xc "uname -s" |& curl -F c=@- https://ptpb.pw/
-bash: syntax error near unexpected token `&'

➔ echo $BASH_VERSION
3.2.57(1)-release
buhman commented 5 years ago

is there an example that doesn't involve shell-quoting?

Sure..

$ bash -x << EOF |& curl -F c=@- https://ptpb.pw/
uname -s
EOF

and the example doesn't work with bash3

ancient/obscure shells are not really interesting, but:

$ bash -xc "uname -s" 2>&1 | curl -F c=@- https://ptpb.pw/
glensc commented 5 years ago

latest macOS /bin/bash is 3.2.57, so it's not that uncommon and the system itself is not ancient.

not sure why they don't update newer, perhaps GPL v2 -> GPL v3 change in bash license not compatible for re-distribution inside the OS?

glensc commented 5 years ago

yep, it's a licensing issue, so system bash 3.2 will stay there: https://apple.stackexchange.com/a/197172