help in named pipes
Hi everyone,
I have a question, I was studying a Linux privilege escalation course, and I came across a systemctl abuse https://gtfobins.github.io/gtfobins/systemctl/#sudo
and then I ask myself why not to do it but get interactive shell, using two named pipes, example:
f1=/tmp/infifo
f2=/tmp/outfifo
mkfifo $f1 $f2
sf=
echo -e "Service\nExecStart=eval \"/bin/bash < $f1 > $f2 &\"\nInstall\nWantedBy=multi-user.target" > $sf
sudo systemctl link $sf
sudo systemctl enable $sf --now
cat $f2 &
cat > $f1
but it did not work, but if I tried it without systemctl, am I using pipes incorrect?
and can you help me understanding named pipes and how to use it?
https://redd.it/1ij1agl
@r_bash
Hi everyone,
I have a question, I was studying a Linux privilege escalation course, and I came across a systemctl abuse https://gtfobins.github.io/gtfobins/systemctl/#sudo
and then I ask myself why not to do it but get interactive shell, using two named pipes, example:
f1=/tmp/infifo
f2=/tmp/outfifo
mkfifo $f1 $f2
sf=
mktemp.serviceecho -e "Service\nExecStart=eval \"/bin/bash < $f1 > $f2 &\"\nInstall\nWantedBy=multi-user.target" > $sf
sudo systemctl link $sf
sudo systemctl enable $sf --now
cat $f2 &
cat > $f1
but it did not work, but if I tried it without systemctl, am I using pipes incorrect?
and can you help me understanding named pipes and how to use it?
https://redd.it/1ij1agl
@r_bash
Authorized one way but unauthorized the other
When I run curl commands independently in iTerm2, I am able to get a file back that I need with no issue. However, when I run those same commands in a bash noscript, I get unauthorized. The tokens are the same both ways. I can give more info if needed, but why would this be happening?
https://redd.it/1ij5qpj
@r_bash
When I run curl commands independently in iTerm2, I am able to get a file back that I need with no issue. However, when I run those same commands in a bash noscript, I get unauthorized. The tokens are the same both ways. I can give more info if needed, but why would this be happening?
https://redd.it/1ij5qpj
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
is anything like "rm all except this, this2, this3"
Hi, I should remove some files.jpg (from 20 +/-) except 3 of them
rm all except DSC1011.jpg Dsc1015.jpg Dsc1020.jpg
what will be the command?
and of course for your GIANT HELPING ALWAYS GENIUSES
https://redd.it/1ijda50
@r_bash
Hi, I should remove some files.jpg (from 20 +/-) except 3 of them
rm all except DSC1011.jpg Dsc1015.jpg Dsc1020.jpg
what will be the command?
and of course for your GIANT HELPING ALWAYS GENIUSES
https://redd.it/1ijda50
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Archstrap - Bootsrap Arch Linux from an existing Linux distro
https://github.com/wick3dr0se/archstrap
https://redd.it/1ikanhw
@r_bash
https://github.com/wick3dr0se/archstrap
https://redd.it/1ikanhw
@r_bash
GitHub
GitHub - wick3dr0se/archstrap: A stupid simple noscript to bootstrap Arch Linux from other Linux distributions
A stupid simple noscript to bootstrap Arch Linux from other Linux distributions - wick3dr0se/archstrap
Depth first or breadth first after learning Linux terminal & Shell noscripting?
Few things on my mind but unsure if I am eligible to learn it..
- gitlab (Mastering gitlab 12)
- Elasticsearch(Not sure of the text to read)
- DNS & BIND (Pro DNS & BIND 10)
- DBA (Pro MySQL)
(Obviously looking into devops route)
https://redd.it/1ikkw26
@r_bash
Few things on my mind but unsure if I am eligible to learn it..
- gitlab (Mastering gitlab 12)
- Elasticsearch(Not sure of the text to read)
- DNS & BIND (Pro DNS & BIND 10)
- DBA (Pro MySQL)
(Obviously looking into devops route)
https://redd.it/1ikkw26
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
line buffering vs block buffering
Hi, after trying appending to a file with
awk -i inplace '{print $0} ENDFILE{print "endoffile"}' somefile
the next command in terminal finish immediately and throws an error with exit status 1:
cat -A
cat: -: input file is output file
Now the `grep` (which has `--line-buffered` as a possible flag) does fine
grep -
So, my suspicion was `awk -i inplace` has done something wrong, and the [inplace extension manual](https://www.gnu.org/software/gawk/manual/htmlnode/Extension-Sample-Inplace.html) does suggest so
>redirect gawk's standard output to /dev/null
Slightly different from suggested, but this works
awk -i inplace '{print $0} ENDFILE{print "endoffile"}' somefile &>/dev/null
also `sed --in-place` has no problem at all
sed -i '$r /dev/stdin' somefile <<< "endoffile"
So what is the cause of this, and is the manual slightly wrong? It doesn't seems
https://redd.it/1ikudxt
@r_bash
Hi, after trying appending to a file with
awk some weird occurrence happenedawk -i inplace '{print $0} ENDFILE{print "endoffile"}' somefile
the next command in terminal finish immediately and throws an error with exit status 1:
cat -A
cat: -: input file is output file
Now the `grep` (which has `--line-buffered` as a possible flag) does fine
grep -
So, my suspicion was `awk -i inplace` has done something wrong, and the [inplace extension manual](https://www.gnu.org/software/gawk/manual/htmlnode/Extension-Sample-Inplace.html) does suggest so
>redirect gawk's standard output to /dev/null
Slightly different from suggested, but this works
awk -i inplace '{print $0} ENDFILE{print "endoffile"}' somefile &>/dev/null
also `sed --in-place` has no problem at all
sed -i '$r /dev/stdin' somefile <<< "endoffile"
So what is the cause of this, and is the manual slightly wrong? It doesn't seems
awk -i inplace is like sed -i emulation, like suggested. Also, is &>/dev/null mandatory to follow inplace extension?https://redd.it/1ikudxt
@r_bash
Learning bash, trying to get it to do something stupid
I'm writing a noscript to handle my code projects, and something stupid I want to add is an ffmpeg command to play every mp3 in a folder after it opens my project in the IDE. Me & GPT (good idea for a romance novel, you're welcome) got this far:
for i in *.mp3; do
ffplay -nodisp -autoexit "/home/scottishcomedian/Music/bash_bullshit/$i"
done
And when I run it, it just hits me with the blank console. What am I doing wrong, oh wise elders?
https://redd.it/1invmde
@r_bash
I'm writing a noscript to handle my code projects, and something stupid I want to add is an ffmpeg command to play every mp3 in a folder after it opens my project in the IDE. Me & GPT (good idea for a romance novel, you're welcome) got this far:
for i in *.mp3; do
ffplay -nodisp -autoexit "/home/scottishcomedian/Music/bash_bullshit/$i"
done
And when I run it, it just hits me with the blank console. What am I doing wrong, oh wise elders?
https://redd.it/1invmde
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
illegal number problem
Hey, I struggle with some noscript.
var="nef892na9s1p9asn2aJs71nIsm"
for counter in {1..40}
do
var=$(echo $var | base64)
if $counter -eq 35
then
echo $var | WC -c
fi
done
It always give me: illegal number: {1..40}
Can someone help?
https://redd.it/1iogfzm
@r_bash
Hey, I struggle with some noscript.
var="nef892na9s1p9asn2aJs71nIsm"
for counter in {1..40}
do
var=$(echo $var | base64)
if $counter -eq 35
then
echo $var | WC -c
fi
done
It always give me: illegal number: {1..40}
Can someone help?
https://redd.it/1iogfzm
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How to parse a nested JSON file in an old unix version
Hi, I'm trying to split a JSON file by transaction_id wherein 1 transaction_id=1 record. However, I feel like my shell noscript is failing due to the fact that it cannot read the JSON file and it won't proceed to processing on what I want it to do. You may see the snippet of my code below.
I hope someone can help I've been losing my mind over this.
https://redd.it/1ip6rpi
@r_bash
Hi, I'm trying to split a JSON file by transaction_id wherein 1 transaction_id=1 record. However, I feel like my shell noscript is failing due to the fact that it cannot read the JSON file and it won't proceed to processing on what I want it to do. You may see the snippet of my code below.
# Extract all transaction_id values using a regular expressionecho "$content" | sed -n 's/.*"transaction_id":\s*"\([^"]*\)".*/\1/p' | while read transaction_id; do# Debugging: Show the current transaction_id being processed and log itecho "Processing transaction_id: $transaction_id" | tee -a "$BATCH_LOG"# Get the last character of the transaction_idlast_char="${transaction_id: -1}"# Debugging: Show the last character of the transaction_id and log itecho "Last character of '$transaction_id': $last_char" | tee -a "$BATCH_LOG"# Check the last character and categorizeif [[ "$last_char" =~ [0-4] ]]; thenecho "$transaction_id" >> "${file%.json}_01.json"# Debugging: Log which file the transaction_id is being saved toecho "Saved to: ${file%.json}_01.json" | tee -a "$BATCH_LOG"elif [[ "$last_char" =~ [5-9] ]]; thenecho "$transaction_id" >> "${file%.json}_02.json"# Debugging: Log which file the transaction_id is being saved toecho "Saved to: ${file%.json}_02.json" | tee -a "$BATCH_LOG"elif [[ "$last_char" =~ [a-l] ]]; thenecho "$transaction_id" >> "${file%.json}_03.json"# Debugging: Log which file the transaction_id is being saved toecho "Saved to: ${file%.json}_03.json" | tee -a "$BATCH_LOG"elif [[ "$last_char" =~ [m-z] ]]; thenecho "$transaction_id" >> "${file%.json}_04.json"# Debugging: Log which file the transaction_id is being saved toecho "Saved to: ${file%.json}_04.json" | tee -a "$BATCH_LOG"else# Debugging: Log unexpected last charactersecho "Unexpected last character '$last_char' for transaction_id: $transaction_id" | tee -a "$BATCH_LOG"fidoneI hope someone can help I've been losing my mind over this.
https://redd.it/1ip6rpi
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Transposing args in noscript, including quotes
I'm trying to create a noscript to interact with my docker containers without having to shell in and run commands manually. It's a very simple noscript:
#!/bin/bash
ALLARGS="$@"
docker compose exec api ash -c "cd ../ && alembic ${ALLARGS}"
I tried a few things (
https://redd.it/1iow04v
@r_bash
I'm trying to create a noscript to interact with my docker containers without having to shell in and run commands manually. It's a very simple noscript:
#!/bin/bash
ALLARGS="$@"
docker compose exec api ash -c "cd ../ && alembic ${ALLARGS}"
I tried a few things (
${ALL_ARGS//\"/\\\"}, sed, others), but finally noticed that "$@" simply doesn't contain the double quotes. Is there a way to transpose the args as is?https://redd.it/1iow04v
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Check if number of arguments is one after all the flag
I have a noscript who can take more than one flag.
So what i have test is if
But if the user type .
if aflag = 1 and (after 'list' is empty)
do something
else
error
So my idea is this on pseudo code. But i don't know how to check dynamicly if the $n+1 after list (
https://redd.it/1ip7zyv
@r_bash
I have a noscript who can take more than one flag.
./noscript -a list is the same than ./noscript list all but list can have other parameter than all so what i want is ./noscript -a list somethingHere give a error.So what i have test is if
$3 is empty when -a is given.But if the user type .
/noscript -a -s list this give a error because $3 is no longer empty but the exeption behavior is to work.if aflag = 1 and (after 'list' is empty)
do something
else
error
So my idea is this on pseudo code. But i don't know how to check dynamicly if the $n+1 after list (
$n) is emptyhttps://redd.it/1ip7zyv
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Unexpected curl command behaviour ?
The following command reads the exchange rate information for the EUR/USD currency pair from HTML page and prints it.
page=$(curl -s https://www.widgets.investing.com/live-currency-cross-rates?theme=darkTheme&pairs=1); echo "$page" | pup 'div.pid-1-bid text{}'
But why doesn't the following command work, instead it prints the entire page?
curl -s https://www.widgets.investing.com/live-currency-cross-rates?theme=darkTheme&pairs=1 | pup 'div.pid-1-bid text{}'
https://redd.it/1imsp0s
@r_bash
The following command reads the exchange rate information for the EUR/USD currency pair from HTML page and prints it.
page=$(curl -s https://www.widgets.investing.com/live-currency-cross-rates?theme=darkTheme&pairs=1); echo "$page" | pup 'div.pid-1-bid text{}'
But why doesn't the following command work, instead it prints the entire page?
curl -s https://www.widgets.investing.com/live-currency-cross-rates?theme=darkTheme&pairs=1 | pup 'div.pid-1-bid text{}'
https://redd.it/1imsp0s
@r_bash
WHAT IS BASH DOING?
**UPDATE**
So it looks like FFPMEG is interacting with the shell in some way... so adding this to the FFPMEG line seems to have resolved the issue.
</dev/null >/dev/null 2>&1
I am doing something dumb... I guess? But I can't figure out what in the heck, when using the EVAL statement, previous variables are stripping off a character for every other loop? Sound confusing? I am confused...
I am using FFMPEG and writing a quick little bash wrapper to automatically detect silences and split apart an audio file.
Let me see if I can show what is going on... This is WITHOUT the eval command...
IFS='\r\n'
while read -r line1; do
IFS= read -r line2
echo "Start: $line1"
echo "End: $line2"
echo "Prev: $PREV"
START="${PREV}"
END="${line1}"
echo "/usr/bin/ffmpeg -hidebanner -loglevel error -i ./${INPUT} -ss ${PREV} -to ${line1} output${COUNT}.wav"
COMMAND='/usr/bin/ffmpeg -hidebanner -loglevel error -i '
COMMAND+="./${INPUT} -ss ${START} -to ${END} output${COUNT}.wav"
echo "${COMMAND}"
# eval ${COMMAND}
COUNT=$(( COUNT + 1 ))
PREV=$line2
echo ''
done <<< $SILENCES
This outputs exactly what I would expect...
Start: 6.04
End: 6.30
Prev: 0
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 0 -to 6.04 output0.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 0 -to 6.04 output0.wav
Start: 21.72
End: 21.98
Prev: 6.30
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 6.30 -to 21.72 output1.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 6.30 -to 21.72 output1.wav
Start: 24.18
End: 24.53
Prev: 21.98
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 21.98 -to 24.18 output2.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 21.98 -to 24.18 output2.wav
Start: 43.34
End: 43.58
Prev: 24.53
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 24.53 -to 43.34 output3.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 24.53 -to 43.34 output3.wav
SO then I uncomment the eval command. That is the only change. I have tried with and without " ", using and not using { } to see if I am interpretting the string differently.
`eval ${COMMAND}`
SOOOO.... Here is the output
Start: 6.04
End: 6.30
Prev: 0
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 0 -to 6.04 output0.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 0 -to 6.04 output0.wav
Start: 1.72
End: 21.98
Prev: 6.30
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 6.30 -to 1.72 output1.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 6.30 -to 1.72 output1.wav
-to value smaller than -ss; aborting.
Start: 24.18
End: 24.53
Prev: 21.98
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 21.98 -to 24.18 output2.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 21.98 -to 24.18 output2.wav
Start: 3.34
End: 43.58
Prev: 24.53
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 24.53 -to 3.34 output3.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 24.53 -to 3.34 output3.wav
-to value smaller than -ss; aborting.
SO Every other iteration... the ${PREV} variable has the first digit/character stripped. So for the second iteration:
21.72 -> 1.72
BUT this ONLY happens when I have the EVAL command AFTER the echo commands. So somehow the eval command is affecting that variable, but I can't see how. Thanks!
https://redd.it/1im9sik
@r_bash
**UPDATE**
So it looks like FFPMEG is interacting with the shell in some way... so adding this to the FFPMEG line seems to have resolved the issue.
</dev/null >/dev/null 2>&1
I am doing something dumb... I guess? But I can't figure out what in the heck, when using the EVAL statement, previous variables are stripping off a character for every other loop? Sound confusing? I am confused...
I am using FFMPEG and writing a quick little bash wrapper to automatically detect silences and split apart an audio file.
Let me see if I can show what is going on... This is WITHOUT the eval command...
IFS='\r\n'
while read -r line1; do
IFS= read -r line2
echo "Start: $line1"
echo "End: $line2"
echo "Prev: $PREV"
START="${PREV}"
END="${line1}"
echo "/usr/bin/ffmpeg -hidebanner -loglevel error -i ./${INPUT} -ss ${PREV} -to ${line1} output${COUNT}.wav"
COMMAND='/usr/bin/ffmpeg -hidebanner -loglevel error -i '
COMMAND+="./${INPUT} -ss ${START} -to ${END} output${COUNT}.wav"
echo "${COMMAND}"
# eval ${COMMAND}
COUNT=$(( COUNT + 1 ))
PREV=$line2
echo ''
done <<< $SILENCES
This outputs exactly what I would expect...
Start: 6.04
End: 6.30
Prev: 0
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 0 -to 6.04 output0.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 0 -to 6.04 output0.wav
Start: 21.72
End: 21.98
Prev: 6.30
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 6.30 -to 21.72 output1.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 6.30 -to 21.72 output1.wav
Start: 24.18
End: 24.53
Prev: 21.98
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 21.98 -to 24.18 output2.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 21.98 -to 24.18 output2.wav
Start: 43.34
End: 43.58
Prev: 24.53
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 24.53 -to 43.34 output3.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 24.53 -to 43.34 output3.wav
SO then I uncomment the eval command. That is the only change. I have tried with and without " ", using and not using { } to see if I am interpretting the string differently.
`eval ${COMMAND}`
SOOOO.... Here is the output
Start: 6.04
End: 6.30
Prev: 0
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 0 -to 6.04 output0.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 0 -to 6.04 output0.wav
Start: 1.72
End: 21.98
Prev: 6.30
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 6.30 -to 1.72 output1.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 6.30 -to 1.72 output1.wav
-to value smaller than -ss; aborting.
Start: 24.18
End: 24.53
Prev: 21.98
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 21.98 -to 24.18 output2.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 21.98 -to 24.18 output2.wav
Start: 3.34
End: 43.58
Prev: 24.53
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 24.53 -to 3.34 output3.wav
/usr/bin/ffmpeg -hidebanner -loglevel error -i ./audio.wav -ss 24.53 -to 3.34 output3.wav
-to value smaller than -ss; aborting.
SO Every other iteration... the ${PREV} variable has the first digit/character stripped. So for the second iteration:
21.72 -> 1.72
BUT this ONLY happens when I have the EVAL command AFTER the echo commands. So somehow the eval command is affecting that variable, but I can't see how. Thanks!
https://redd.it/1im9sik
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How can I combine these two awk commands?
This command gives me the latest version of Powershell. I just want the result from the last line. How can I add the END rule to the first awk command?
https://redd.it/1ik223z
@r_bash
git ls-remote -t `https://github.com/PowerShell/PowerShell.git` | awk -e '$2 ~ /v[0-9].[0-9].[0-9]$/ {sub(/refs\/tags\/v/,"");print $2}' | awk 'END {print}'This command gives me the latest version of Powershell. I just want the result from the last line. How can I add the END rule to the first awk command?
https://redd.it/1ik223z
@r_bash
GitHub
GitHub - PowerShell/PowerShell: PowerShell for every system!
PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
Does anyone know of an interactive BASH command builder that is built with BASH noscripts?
I'd love to have an interactive shell environment that helps students new to BASH navigates its opacity and easily survey the breadth of options. I would also like it for myself, since one can always learn more.
This is especially useful when BASH is required for a subject like Practical Control Theory with Python but is not the subject of the class. Think of it as a nice gateway drug for BASH.
And while I'm asking for ponies, I think it would be best to make this run natively inside terminal emulators. So writing it as a BASH noscript would be great.
https://redd.it/1iq37l3
@r_bash
I'd love to have an interactive shell environment that helps students new to BASH navigates its opacity and easily survey the breadth of options. I would also like it for myself, since one can always learn more.
This is especially useful when BASH is required for a subject like Practical Control Theory with Python but is not the subject of the class. Think of it as a nice gateway drug for BASH.
And while I'm asking for ponies, I think it would be best to make this run natively inside terminal emulators. So writing it as a BASH noscript would be great.
https://redd.it/1iq37l3
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Could anyone show me how parallel works?
Does anyone have good examples of how 'parallel' can work with bash functions or noscripts? I have several for processing filetypes that I'd like to make happen more quickly
https://redd.it/1iqaw6o
@r_bash
Does anyone have good examples of how 'parallel' can work with bash functions or noscripts? I have several for processing filetypes that I'd like to make happen more quickly
https://redd.it/1iqaw6o
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Help with login noscript
I have created two login noscripts, one of which is working wonderfully. However, the other only works under certain conditions and I need some help making it more circumstance independent. Here's what I mean:
Both noscripts are for starting Google Chrome PWAs and then docking them to my system tray with kdocker. The first one is for Google Messages and the second is for Gmail.
Here is the first noscript:
#!/bin/bash
# Start Messages
/opt/google/chrome/google-chrome --profile-directory=Default --app-id=hpfldicfbfomlpcikngkocigghgafkph &
# Set ID variable
messages=$(xdotool search --sync --name "Messages - Google Messages for web")
# Pin to tray
kdocker -w $messages -i /home/ego/.local/share/icons/hicolor/128x128/apps/chrome-hpfldicfbfomlpcikngkocigghgafkph-Default.png &
# Quit
exit
And here is the second:
#!/bin/bash
# Start Gmail
/opt/google/chrome/google-chrome --profile-directory=Default --app-id=fmgjjmmmlfnkbppncabfkddbjimcfncm &
# Set ID variable
gmail=$(xdotool search --sync --name "Gmail - Inbox - myemail@gmail.com - Gmail")
# Pin to tray
kdocker -w $gmail -i /home/ego/.local/share/icons/hicolor/128x128/apps/chrome-fmgjjmmmlfnkbppncabfkddbjimcfncm-Default.png &
# Quit
exit
The problem with the Gmail noscript is that this string:
https://redd.it/1iq7bko
@r_bash
I have created two login noscripts, one of which is working wonderfully. However, the other only works under certain conditions and I need some help making it more circumstance independent. Here's what I mean:
Both noscripts are for starting Google Chrome PWAs and then docking them to my system tray with kdocker. The first one is for Google Messages and the second is for Gmail.
Here is the first noscript:
#!/bin/bash
# Start Messages
/opt/google/chrome/google-chrome --profile-directory=Default --app-id=hpfldicfbfomlpcikngkocigghgafkph &
# Set ID variable
messages=$(xdotool search --sync --name "Messages - Google Messages for web")
# Pin to tray
kdocker -w $messages -i /home/ego/.local/share/icons/hicolor/128x128/apps/chrome-hpfldicfbfomlpcikngkocigghgafkph-Default.png &
# Quit
exit
And here is the second:
#!/bin/bash
# Start Gmail
/opt/google/chrome/google-chrome --profile-directory=Default --app-id=fmgjjmmmlfnkbppncabfkddbjimcfncm &
# Set ID variable
gmail=$(xdotool search --sync --name "Gmail - Inbox - myemail@gmail.com - Gmail")
# Pin to tray
kdocker -w $gmail -i /home/ego/.local/share/icons/hicolor/128x128/apps/chrome-fmgjjmmmlfnkbppncabfkddbjimcfncm-Default.png &
# Quit
exit
The problem with the Gmail noscript is that this string:
Gmail - Inbox - myemail@gmail.com - Gmail changes based on how many emails I have in my inbox. For example, if I have three emails, it will read: Gmail - Inbox (3) - myemail@gmail.com - Gmail. This causes xdotool to not find it and subsequently causes kdocker to fail to pin it in the system tray unless I specifically have zero unread messages in my inbox, which is obviously not ideal. Can anybody help me figure out a better way to target the windows in both of my noscripts so that they are able to find the correct window in more varying conditions?https://redd.it/1iq7bko
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
printf
There are 3 places you can get info on how to use printf in bash. One is by consulting the bash man page (or help), because bash's builtin printf command is used by default. But you probably also have an installed printf command. For example, at /usr/bin/printf. So you can check
Using all of that, I came up with this printf command that I put in my PS1:
The argument to the format string (the seq) gets the current width of the terminal window, as an integer, and then spits out that many arguments, in the form of number strings. The format string produces a Unicode character and then one of the string arguments converted to zero-width. A zero-width string is literally just "". So the printf is printing the Unicode character and then nothing. But because there are, say, 100 string arguments, it'll repeat this over and over again, that many times.
The reason I came up with this is because, for a while, I was having trouble seeing where one command ran and ended when I was scrolling through my terminal window history. This printf creates a nice visual barrier that's easy to catch even when you're scrolling in the window.
Anyway, I thought it was pretty clever so I wanted to share with you guys.
https://redd.it/1iq782d
@r_bash
There are 3 places you can get info on how to use printf in bash. One is by consulting the bash man page (or help), because bash's builtin printf command is used by default. But you probably also have an installed printf command. For example, at /usr/bin/printf. So you can check
man 1 printf. There's also the printf library, which you can read about in man 3 printf. Even though bash has printf builtin, it depends on the printf library, and so some of the stuff in the two man pages applies to the builtin command as well.Using all of that, I came up with this printf command that I put in my PS1:
printf "\\u2501%.0s" $(seq "$(tput cols)")The argument to the format string (the seq) gets the current width of the terminal window, as an integer, and then spits out that many arguments, in the form of number strings. The format string produces a Unicode character and then one of the string arguments converted to zero-width. A zero-width string is literally just "". So the printf is printing the Unicode character and then nothing. But because there are, say, 100 string arguments, it'll repeat this over and over again, that many times.
The reason I came up with this is because, for a while, I was having trouble seeing where one command ran and ended when I was scrolling through my terminal window history. This printf creates a nice visual barrier that's easy to catch even when you're scrolling in the window.
Anyway, I thought it was pretty clever so I wanted to share with you guys.
https://redd.it/1iq782d
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Here're 22 best free video converter software and online apps that you can use to convert video formats without any cost.
https://www.videoproc.com/media-converter/best-video-converter.htm
https://redd.it/1iqowa9
@r_bash
https://www.videoproc.com/media-converter/best-video-converter.htm
https://redd.it/1iqowa9
@r_bash
Videoproc
9 Best Free Video Converters for PC and Mac (Compared)
Need the best video converter for Windows & Mac? This curated list covers truly free video converters and top-value paid options for all your conversion needs.
Where do you store reusable code snippets?
Hey folks! Curios where do you store your code snippets? If you work in a team how do you manage it?
https://redd.it/1iqwadh
@r_bash
Hey folks! Curios where do you store your code snippets? If you work in a team how do you manage it?
https://redd.it/1iqwadh
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community