Output somehow "escaping" from inside variable
I'm trying to create a noscript for detecting the current song in quodlibet. It all works perfectly except for one strange thing: everything works, except when there's a certain output. Here it is:
​
​
This output refuses to be assigned to a variable, and gets output into stdout.
​
​
If a song is playing, it works just fine
​
I'm puzzled. Is it the "--run" which is causing problems?
https://redd.it/xjg8xk
@r_bash
I'm trying to create a noscript for detecting the current song in quodlibet. It all works perfectly except for one strange thing: everything works, except when there's a certain output. Here it is:
​
$ quodlibet --print-playingQuod Libet is not running (add '--run' to start it)​
This output refuses to be assigned to a variable, and gets output into stdout.
​
$ songstat=$(quodlibet --print-playing)Quod Libet is not running (add '--run' to start it)$ echo $songstat[something else]​
If a song is playing, it works just fine
$ songstat=$(quodlibet --print-playing)$ echo $songstatDean Martin - Mambo Italiano​
I'm puzzled. Is it the "--run" which is causing problems?
https://redd.it/xjg8xk
@r_bash
reddit
Output somehow "escaping" from inside variable
I'm trying to create a noscript for detecting the current song in quodlibet. It all works perfectly except for one strange thing: everything works,...
i need help with bash (18f)
we can be friends but please i really need help with this bash lab so kind of a tutor
https://redd.it/xjnywx
@r_bash
we can be friends but please i really need help with this bash lab so kind of a tutor
https://redd.it/xjnywx
@r_bash
reddit
i need help with bash (18f)
we can be friends but please i really need help with this bash lab so kind of a tutor
Need help with capturing date and time in my output
Hi all,
I made a shocking discovery today that my audit.log and rotations are not being uploaded. So I have about a years worth of rotations and I need to rename them based on their date. I created a noscript that is doing it pretty well but I also need to capture HH:mm:ss which I am struggling with.
for T in $(ls /var/log/audit); do TIMESTAMP=$(stat -c %y $T | awk '{ print $1 }'); mv $T audit-$TIMESTAMP.log; done
# Jun 14 2022 05:00 audit.log.500 -> audit-2022-06-14.log
# I want audit-2022-06-14-05-00.log
I found a sed command that does ALMOST what I need but I dont understand this command so I dont know how to edit it to pull what I need (its pulling HH:mm but not ss).
Am I on the right track? I am too new at shell to full understand how to pull this off.
https://redd.it/xjnxji
@r_bash
Hi all,
I made a shocking discovery today that my audit.log and rotations are not being uploaded. So I have about a years worth of rotations and I need to rename them based on their date. I created a noscript that is doing it pretty well but I also need to capture HH:mm:ss which I am struggling with.
for T in $(ls /var/log/audit); do TIMESTAMP=$(stat -c %y $T | awk '{ print $1 }'); mv $T audit-$TIMESTAMP.log; done
# Jun 14 2022 05:00 audit.log.500 -> audit-2022-06-14.log
# I want audit-2022-06-14-05-00.log
I found a sed command that does ALMOST what I need but I dont understand this command so I dont know how to edit it to pull what I need (its pulling HH:mm but not ss).
sed 's/.* \([0-9]*:[0-9]*\):[0-9]*.*/\1\'Am I on the right track? I am too new at shell to full understand how to pull this off.
https://redd.it/xjnxji
@r_bash
reddit
Need help with capturing date and time in my output
Hi all, I made a shocking discovery today that my audit.log and rotations are not being uploaded. So I have about a years worth of rotations and...
How to check with xrandr if monitor has output
Hi everyone
I try to modify my launch.sh noscript for polybar such that it works for my multi monitor setup.
My problem is, that I have a laptop and in my home office I have two 27 inch monitors. So when I am at home I set via xrandr the --output of my laptop screen to --off.
Is there a way to detect if the monitor output is on or off?
Because now I have a noscript which starts for every connected monitor a polybar but my laptop screen still counts as connected even the output is off (which is correct of course).
I don't want to just exclude my laptop screen since I sometimes just use the laptop of course.
The only workaround which I can think of now, is to check if more than one Monitor is connected and if so exclude my laptop screen otherwise use it only there. But I wanted to know if there is a better way
Thank you
https://redd.it/xjxkof
@r_bash
Hi everyone
I try to modify my launch.sh noscript for polybar such that it works for my multi monitor setup.
My problem is, that I have a laptop and in my home office I have two 27 inch monitors. So when I am at home I set via xrandr the --output of my laptop screen to --off.
Is there a way to detect if the monitor output is on or off?
Because now I have a noscript which starts for every connected monitor a polybar but my laptop screen still counts as connected even the output is off (which is correct of course).
I don't want to just exclude my laptop screen since I sometimes just use the laptop of course.
The only workaround which I can think of now, is to check if more than one Monitor is connected and if so exclude my laptop screen otherwise use it only there. But I wanted to know if there is a better way
Thank you
https://redd.it/xjxkof
@r_bash
reddit
How to check with xrandr if monitor has output
Hi everyone I try to modify my launch.sh noscript for polybar such that it works for my multi monitor setup. My problem is, that I have a laptop...
There seems to be process occupying port 2181 which is Java
I'm trying to launch program zookeeper which use default port 2181, however it shows error saying that the address is being used.
After I test with netstat:
It shows this:
​
I'm not sure if this process is the Java program. If it is, then I couldn't shut the process down since I need it.
​
Could anyone help me identify what process exactly is this? Thanks!
https://redd.it/xk6eb6
@r_bash
I'm trying to launch program zookeeper which use default port 2181, however it shows error saying that the address is being used.
After I test with netstat:
netstat -tulpn | grep :2181 It shows this:
tcp6 1 0 :::2181 :::* LISTEN 279/java​
I'm not sure if this process is the Java program. If it is, then I couldn't shut the process down since I need it.
​
Could anyone help me identify what process exactly is this? Thanks!
https://redd.it/xk6eb6
@r_bash
reddit
There seems to be process occupying port 2181 which is Java
I'm trying to launch program zookeeper which use default port 2181, however it shows error saying that the address is being used. After I test...
How do I make a condition based on whether $2 is set when I run my noscript?
So I have a noscript called vimcode that basically just sets up a project folder for my C++ code and starts writing in vim. I don't know if I have the most efficient way of writing it, but that part will be pretty clear once you read the noscript. That works, but I wanted to set up a second option that will start writing a file with a specific name because
With how I have it currently written it opens up
Here is what I have currently written
#!/bin/bash
CODEDIR="$HOME/Documents/code"
#Make project dir if it doesn't exit
if [ -d "$CODEDIR/$1/" ]; then
:
else
mkdir "$CODEDIR/$1"
fi
#Check for $2 before opening a file, open $2 if it is set
if [ -v $2 ]; then
nvim "$CODEDIR/$1/$2"
else
#If $2 is not set, open $1, if it does not exist, copy the template
if [ -f "$CODEDIR/$1/$1.cpp" ]; then
nvim "$CODEDIR/$1/$1.cpp"
else
cp "$CODEDIR/template.cpp" "$CODEDIR/$1/$1.cpp" && nvim "$CODEDIR/$1/$1.cpp"
fi
fi
https://redd.it/xka9mt
@r_bash
So I have a noscript called vimcode that basically just sets up a project folder for my C++ code and starts writing in vim. I don't know if I have the most efficient way of writing it, but that part will be pretty clear once you read the noscript. That works, but I wanted to set up a second option that will start writing a file with a specific name because
vimcode <project> will create <project>/<project>.cpp, so a specific file would be done with vimcode <project> example.h, I want this to create <project>/example.hWith how I have it currently written it opens up
<project>/<project>.cpp even when I write the second option. However, the way I have it checking for the second option is with [[ -v $2 ]], I dont know if that is valid or not.Here is what I have currently written
#!/bin/bash
CODEDIR="$HOME/Documents/code"
#Make project dir if it doesn't exit
if [ -d "$CODEDIR/$1/" ]; then
:
else
mkdir "$CODEDIR/$1"
fi
#Check for $2 before opening a file, open $2 if it is set
if [ -v $2 ]; then
nvim "$CODEDIR/$1/$2"
else
#If $2 is not set, open $1, if it does not exist, copy the template
if [ -f "$CODEDIR/$1/$1.cpp" ]; then
nvim "$CODEDIR/$1/$1.cpp"
else
cp "$CODEDIR/template.cpp" "$CODEDIR/$1/$1.cpp" && nvim "$CODEDIR/$1/$1.cpp"
fi
fi
https://redd.it/xka9mt
@r_bash
reddit
How do I make a condition based on whether $2 is set when I run my...
So I have a noscript called vimcode that basically just sets up a project folder for my C++ code and starts writing in vim. I don't know if I have...
How to echo #!/bin/bash into a file
I want to use the echo command from the linux shell to create a file that has the line #!/bin/bash
At first I tried the command
echo -e "#!/bin/bash" >> file.txt
but this had a bash error for the ! so I tried
echo -e "#\!/bin/bash" >> file.txt
but this just makes a file with #\\!/bin/bash
What is the proper way to echo only #!/bin/bash into a file?
https://redd.it/xki11l
@r_bash
I want to use the echo command from the linux shell to create a file that has the line #!/bin/bash
At first I tried the command
echo -e "#!/bin/bash" >> file.txt
but this had a bash error for the ! so I tried
echo -e "#\!/bin/bash" >> file.txt
but this just makes a file with #\\!/bin/bash
What is the proper way to echo only #!/bin/bash into a file?
https://redd.it/xki11l
@r_bash
reddit
How to echo #!/bin/bash into a file
I want to use the echo command from the linux shell to create a file that has the line #!/bin/bash At first I tried the command echo -e...
Looking for conceptual feedback on a noscript I am writing to update docker containers
I hope this isn't too much docker blah blah blah, but everything I'm writing is bash. I'm hoping there is some overlap that's acceptable here.
I realize watchtower exists, but I don't like it. I don't like not having control for how mature (how old) a docker image must be or individual control to potentially manipulate settings if I want. So the noscript I am writing has a minimum age that a repo must be before it is considered stable enough to install.
watchtower is written in Go. What I am working on is 100% bash. Here is the current output from my noscript as an example of what it is reading/scraping/comparing:
----
Repository Tag dAge Container iAge Status
---------- ---- --- --------- ---- ------
henrywhitaker3/speedtest-tracker latest 505 speedtest-tracker 505 SAME (1620136341=1620136341)
homeassistant/home-assistant stable 2 homeassistant 7 NEWER (1663544392>1663147322)
jez500/bender latest 13 bender 13 SAME (1662615615=1662615616)
openspeedtest/latest latest 6 openspeedtest 34 NEWER (1663260272>1660824207)
pihole/pihole latest 2 pihole 7 NEWER (1663584081>1663188503)
portainer/portainer-ce latest 6 portainer 16 NEWER (1663276762>1662412237)
r0gger/docker-wsusoffline latest 49 OFFLINE 49 SAME (1659478477=1659478477)
vaultwarden/server latest 56 vaultwarden 56 SAME (1658948175=1658948175)
Minimum dAge: 3
------------
Run Script: .\runScripts\openspeedtestRunScript.sh
Run Script: .\runScripts\portainerRunScript.sh
----
So, in this example, although there are (4) container images that have updates - only (2) of them are eligible for my noscript to process/update because I have set a minimum age requirement of (3). Right now the noscript isn't actually doing anything (because this is still a conceptual WIP), and I'm wondering (by asking you fine folks) if this is worthwhile endeavor or if I'm wasting my time.
My concept for the container-name-matched runScripts would be to directly issue docker run commands, docker-compose, etc. to facilitate an update. Here's an example:
----
#!/bin/bash
###### PI-HOLE (HOST:8125)
docker pull pihole/pihole:latest
docker stop pihole
docker rm pihole
docker run --detach \
--name pihole \
--restart unless-stopped \
--network host \
--hostname pihole \
--volume /volume1/docker/pihole/pihole:/etc/pihole \
--volume /volume1/docker/pihole/dnsmasq.d:/etc/dnsmasq.d \
--env WEBPORT="8125" \
--env DNSMASQLISTENING="local" \
--env DNSMASQUSER="root" \
--env DNSMASQPARAMS="--dns-forward-max=300" \
--env TZ="America/LosAngeles" \
--env VIRTUALHOST="pihole" \
--env PROXYLOCATION="pihole" \
--cap-add NETADMIN \
pihole/pihole:latest
----
My work so far is some local scraping and some repository scraping, mostly depending on jq, timestamp manipulation, and some basic math. I'm currently developing against unique container names and not image IDs. I'm probably going to personally run this no matter what, and the code will be hosted on GitHub at a later date.
So, is this concept good, bad, ugly, stupid? Give it to me as straight as can be. Thanks!
edit: The container marked as "OFFLINE" is actually offline. Its not actively running
https://redd.it/xkix1w
@r_bash
I hope this isn't too much docker blah blah blah, but everything I'm writing is bash. I'm hoping there is some overlap that's acceptable here.
I realize watchtower exists, but I don't like it. I don't like not having control for how mature (how old) a docker image must be or individual control to potentially manipulate settings if I want. So the noscript I am writing has a minimum age that a repo must be before it is considered stable enough to install.
watchtower is written in Go. What I am working on is 100% bash. Here is the current output from my noscript as an example of what it is reading/scraping/comparing:
----
Repository Tag dAge Container iAge Status
---------- ---- --- --------- ---- ------
henrywhitaker3/speedtest-tracker latest 505 speedtest-tracker 505 SAME (1620136341=1620136341)
homeassistant/home-assistant stable 2 homeassistant 7 NEWER (1663544392>1663147322)
jez500/bender latest 13 bender 13 SAME (1662615615=1662615616)
openspeedtest/latest latest 6 openspeedtest 34 NEWER (1663260272>1660824207)
pihole/pihole latest 2 pihole 7 NEWER (1663584081>1663188503)
portainer/portainer-ce latest 6 portainer 16 NEWER (1663276762>1662412237)
r0gger/docker-wsusoffline latest 49 OFFLINE 49 SAME (1659478477=1659478477)
vaultwarden/server latest 56 vaultwarden 56 SAME (1658948175=1658948175)
Minimum dAge: 3
------------
Run Script: .\runScripts\openspeedtestRunScript.sh
Run Script: .\runScripts\portainerRunScript.sh
----
So, in this example, although there are (4) container images that have updates - only (2) of them are eligible for my noscript to process/update because I have set a minimum age requirement of (3). Right now the noscript isn't actually doing anything (because this is still a conceptual WIP), and I'm wondering (by asking you fine folks) if this is worthwhile endeavor or if I'm wasting my time.
My concept for the container-name-matched runScripts would be to directly issue docker run commands, docker-compose, etc. to facilitate an update. Here's an example:
----
#!/bin/bash
###### PI-HOLE (HOST:8125)
docker pull pihole/pihole:latest
docker stop pihole
docker rm pihole
docker run --detach \
--name pihole \
--restart unless-stopped \
--network host \
--hostname pihole \
--volume /volume1/docker/pihole/pihole:/etc/pihole \
--volume /volume1/docker/pihole/dnsmasq.d:/etc/dnsmasq.d \
--env WEBPORT="8125" \
--env DNSMASQLISTENING="local" \
--env DNSMASQUSER="root" \
--env DNSMASQPARAMS="--dns-forward-max=300" \
--env TZ="America/LosAngeles" \
--env VIRTUALHOST="pihole" \
--env PROXYLOCATION="pihole" \
--cap-add NETADMIN \
pihole/pihole:latest
----
My work so far is some local scraping and some repository scraping, mostly depending on jq, timestamp manipulation, and some basic math. I'm currently developing against unique container names and not image IDs. I'm probably going to personally run this no matter what, and the code will be hosted on GitHub at a later date.
So, is this concept good, bad, ugly, stupid? Give it to me as straight as can be. Thanks!
edit: The container marked as "OFFLINE" is actually offline. Its not actively running
https://redd.it/xkix1w
@r_bash
reddit
Looking for conceptual feedback on a noscript I am writing to update...
I hope this isn't too much docker blah blah blah, but everything I'm writing is bash. I'm hoping there is some overlap that's acceptable here. I...
How exactly does ${!OPTIND} work in getopts?
I wrote a noscript to try and understand using long arguments in getopts, but don't really get what the
while getopts 'abc:-:' OPT; do
echo -e "${OPT}\t${OPTIND}\t${OPTARG}"
case ${OPT} in
-)
case ${OPTARG} in
version)
echo "OPT: ${OPT}"
echo "OPTARG: ${OPTART}"
echo "OPTIND: ${OPTIND}"
echo "!OPTIND: ${!OPTIND}"
(( OPTIND++ ))
;;
esac
esac
done
Output:
$ ./test.sh -ab -c FOO --version 1.23
a 1
b 2
c 4 FOO
- 5 version
OPT: -
OPTARG:
OPTIND: 5
!OPTIND: 1.23
So, from what I can gather from the output,
​
>If the first character of "PARAMETER" is an exclamation point, Bash uses the value of the variable formed from the rest of "PARAMETER" as the name of the variable; this variable is then expanded and that value is used in the rest of the substitution, rather than the value of "PARAMETER" itself.
Is this some kind of indirect expansion on an array?
https://redd.it/xkoi3u
@r_bash
I wrote a noscript to try and understand using long arguments in getopts, but don't really get what the
! operator is doing. If ${OPTIND} is the index value of the next argument, then how exactly does ${!OPTIND} work to get the value for --version?while getopts 'abc:-:' OPT; do
echo -e "${OPT}\t${OPTIND}\t${OPTARG}"
case ${OPT} in
-)
case ${OPTARG} in
version)
echo "OPT: ${OPT}"
echo "OPTARG: ${OPTART}"
echo "OPTIND: ${OPTIND}"
echo "!OPTIND: ${!OPTIND}"
(( OPTIND++ ))
;;
esac
esac
done
Output:
$ ./test.sh -ab -c FOO --version 1.23
a 1
b 2
c 4 FOO
- 5 version
OPT: -
OPTARG:
OPTIND: 5
!OPTIND: 1.23
So, from what I can gather from the output,
--version is at the fourth index, and 1.23 would be at the fifth index (which is why we use (( OPTIND++ )) to skip to the next argument, which would subsequently be positioned at the sixth index, if another argument were present). But how exactly is ! getting the value at the fifth index? From the documentation on shell expansion, it seems that this has something to do with indirect expansion:​
>If the first character of "PARAMETER" is an exclamation point, Bash uses the value of the variable formed from the rest of "PARAMETER" as the name of the variable; this variable is then expanded and that value is used in the rest of the substitution, rather than the value of "PARAMETER" itself.
Is this some kind of indirect expansion on an array?
https://redd.it/xkoi3u
@r_bash
How to write a noscript to capture the banner of a ssh session ? (bash or expect?)
I’m trying to write a noscript that would open a ssh session, read the « welcome banner », parse it and store it. I started using expect and so far I’m able to do the basics: open the session and later close it. What I miss is the way to « capture » the banner (where it says last login from ip, date, etc…). The goal is for the noscript to connect to multiple server, extract the ip/date of the last login and store it (in a cab or a db, not sure yet). Any idea ?
https://redd.it/xkovuv
@r_bash
I’m trying to write a noscript that would open a ssh session, read the « welcome banner », parse it and store it. I started using expect and so far I’m able to do the basics: open the session and later close it. What I miss is the way to « capture » the banner (where it says last login from ip, date, etc…). The goal is for the noscript to connect to multiple server, extract the ip/date of the last login and store it (in a cab or a db, not sure yet). Any idea ?
https://redd.it/xkovuv
@r_bash
reddit
How to write a noscript to capture the banner of a ssh session ?...
I’m trying to write a noscript that would open a ssh session, read the « welcome banner », parse it and store it. I started using expect and so far...
Is it faster to run mkdir every time than to put it in an if statement to check if the dir exists?
I posted about a noscript here recently and a lot of people commented on running mkdir in an if statement, that I shouldn't do it. I understand that mkdir just doesn't need that because it will return 0. What if this was your bashrc and you had some custom directories that it required? Should you let mkdir return 0 every time bash runs or is it faster to just check for the dir?
So what is faster? 'if [ -d dir ];' or 'mkdir dir' assuming 'dir' exists? Is there an even faster way to handle dir checking? Speed doesn't really matter in the single instance that it will run and the dirs don't exist, only in every instance after.
https://redd.it/xkqhfd
@r_bash
I posted about a noscript here recently and a lot of people commented on running mkdir in an if statement, that I shouldn't do it. I understand that mkdir just doesn't need that because it will return 0. What if this was your bashrc and you had some custom directories that it required? Should you let mkdir return 0 every time bash runs or is it faster to just check for the dir?
So what is faster? 'if [ -d dir ];' or 'mkdir dir' assuming 'dir' exists? Is there an even faster way to handle dir checking? Speed doesn't really matter in the single instance that it will run and the dirs don't exist, only in every instance after.
https://redd.it/xkqhfd
@r_bash
reddit
Is it faster to run mkdir every time than to put it in an if...
I posted about a noscript here recently and a lot of people commented on running mkdir in an if statement, that I shouldn't do it. I understand that...
Change string format
Hi all
I want to take DATEORIGINAL="202209" and set DATENEW to 2022-09. I used a case and it worked but that's very static.
Originally it's 20220921 so I did a DATEORIGINAL=${date long::-2} to strip day. Now I want to add that hyphen.
What's the best way to go about it?
https://redd.it/xkoo99
@r_bash
Hi all
I want to take DATEORIGINAL="202209" and set DATENEW to 2022-09. I used a case and it worked but that's very static.
Originally it's 20220921 so I did a DATEORIGINAL=${date long::-2} to strip day. Now I want to add that hyphen.
What's the best way to go about it?
https://redd.it/xkoo99
@r_bash
reddit
Change string format
Hi all I want to take DATEORIGINAL="202209" and set DATENEW to 2022-09. I used a case and it worked but that's very static. Originally it's...
Find string 3 times in the file
Staff,
I created the function below that is locating in the directory files "/X/X/logs" the string I was looking for.
What I need now is for the noscript to verify that the string was found 3 or more times inside the file. If show up 1 or 2, shouldn't let me know.
Does anyone know how I could do that?
Grateful for any idea.
function check\_logs {
FLAG=\`find /X/X/logs -type f -exec grep -l 'String' {} +;\`
if \[\[ ! -z ${FLAG} \]\]; then
printf "Found:\\n\\n${FLAG}\\n"
else
echo "Not found"
fi
}
EDIT: formatting
​
https://redd.it/xkvkcr
@r_bash
Staff,
I created the function below that is locating in the directory files "/X/X/logs" the string I was looking for.
What I need now is for the noscript to verify that the string was found 3 or more times inside the file. If show up 1 or 2, shouldn't let me know.
Does anyone know how I could do that?
Grateful for any idea.
function check\_logs {
FLAG=\`find /X/X/logs -type f -exec grep -l 'String' {} +;\`
if \[\[ ! -z ${FLAG} \]\]; then
printf "Found:\\n\\n${FLAG}\\n"
else
echo "Not found"
fi
}
EDIT: formatting
​
https://redd.it/xkvkcr
@r_bash
reddit
Find string 3 times in the file
Staff, I created the function below that is locating in the directory files "**/X/X/logs**" the string I was looking for. What I need now is for...
Help😅
I’ve used this sed command: sed-i's/\/\n/g;s/\>/\n/g;' <TextFile>
Is there any way to do the same without using sed, for example «tr» command?
https://redd.it/xkwfhn
@r_bash
I’ve used this sed command: sed-i's/\/\n/g;s/\>/\n/g;' <TextFile>
Is there any way to do the same without using sed, for example «tr» command?
https://redd.it/xkwfhn
@r_bash
reddit
Help😅
I’ve used this sed command: sed-i's/\/\n/g;s/\>/\n/g;' <TextFile> Is there any way to do the same without using sed, for example «tr» command?
Recording footage from a press of a button!
Hi yall,
Just a heads up, I am using a Raspberry Pi 3. I am attempting to record footage from my webcam through the raspberry pi. I am interested in having this done through terminal - no gui. The code below works well but I have to manually stop the code and it always saves as "out0001.mkv".
>ffmpeg -f v4l2 -standard PAL -threadqueuesize 512 -i /dev/video0 -f alsa -threadqueuesize 512 -i hw:0,0 -vcodec libx264 -preset superfast -crf 25 -s 640x480 -r 25 -aspect 16:9 -acodec libmp3lame -b:a 128k -channels 2 -ar 48000 out0001.mkv
so i have a question: Is there a way to set it up so that I could press a physical button that's connected to the Raspberry Pi's GPIO so it can start and stop a recording?
Another question: is it possible to have it save in a new file every time i finish a recording automatically so what I mean by this is that the first file would be out0001.mkv
second round of recording, it checks if out0001.mkv exists, if it does, it would instead save the new footage as out0002.mkv and if both out0001.mkv and out0002.mkv exists - it would save as out0003.mkv and so forth.
Any help would be appreciated. Thanks :D
https://redd.it/xkyrhd
@r_bash
Hi yall,
Just a heads up, I am using a Raspberry Pi 3. I am attempting to record footage from my webcam through the raspberry pi. I am interested in having this done through terminal - no gui. The code below works well but I have to manually stop the code and it always saves as "out0001.mkv".
>ffmpeg -f v4l2 -standard PAL -threadqueuesize 512 -i /dev/video0 -f alsa -threadqueuesize 512 -i hw:0,0 -vcodec libx264 -preset superfast -crf 25 -s 640x480 -r 25 -aspect 16:9 -acodec libmp3lame -b:a 128k -channels 2 -ar 48000 out0001.mkv
so i have a question: Is there a way to set it up so that I could press a physical button that's connected to the Raspberry Pi's GPIO so it can start and stop a recording?
Another question: is it possible to have it save in a new file every time i finish a recording automatically so what I mean by this is that the first file would be out0001.mkv
second round of recording, it checks if out0001.mkv exists, if it does, it would instead save the new footage as out0002.mkv and if both out0001.mkv and out0002.mkv exists - it would save as out0003.mkv and so forth.
Any help would be appreciated. Thanks :D
https://redd.it/xkyrhd
@r_bash
reddit
Recording footage from a press of a button!
Hi yall, Just a heads up, I am using a Raspberry Pi 3. I am attempting to record footage from my webcam through the raspberry pi. I am interested...
Symlink the contents of a directory, in to another, preserving structure.
Hi,
I've been trying to figure this out for a while and my brain just hurts...like I've literally given myself a headache trying to figure this out as it used to be junk I could handle in five minutes. (brain-fog sucks)
I run a Jekyll based site that's built every repo push with a githook. That part works fine. What I'm having issue with is some "extra" stuff I do after the jekyll rendering related to symlinking files. When Jekyll builds the site, it naturally just wipes out the root directory and builds one from scratch.
My problem is I do not keep all of my stuff in the repo. I have a lot of images and other content that I clearly don't want in the repo. So what I want to do is setup a directory that contains all the non jekyll content in the usual folder structure. So if my site is in /var/www/sitename then I might keep the static content in /var/www/sitename-static. So I came up with the easy solution:
​
>ln -s /var/www/sitename-static/* /var/www/sitename/
This accomplishes what I want...mostly. The contents and all the directories in -static show up in sitename perfectly...except in cases where the folder already exists. It doesn't just error out on trying to symlink the folder; but it ignores all the files.
Right now I feel like I'd have to for-loop every folder in every sub-directory to make this work. I feel like I used to know the solution but my mush-brain can't retrieve it anymore.
https://redd.it/xl64tm
@r_bash
Hi,
I've been trying to figure this out for a while and my brain just hurts...like I've literally given myself a headache trying to figure this out as it used to be junk I could handle in five minutes. (brain-fog sucks)
I run a Jekyll based site that's built every repo push with a githook. That part works fine. What I'm having issue with is some "extra" stuff I do after the jekyll rendering related to symlinking files. When Jekyll builds the site, it naturally just wipes out the root directory and builds one from scratch.
My problem is I do not keep all of my stuff in the repo. I have a lot of images and other content that I clearly don't want in the repo. So what I want to do is setup a directory that contains all the non jekyll content in the usual folder structure. So if my site is in /var/www/sitename then I might keep the static content in /var/www/sitename-static. So I came up with the easy solution:
​
>ln -s /var/www/sitename-static/* /var/www/sitename/
This accomplishes what I want...mostly. The contents and all the directories in -static show up in sitename perfectly...except in cases where the folder already exists. It doesn't just error out on trying to symlink the folder; but it ignores all the files.
Right now I feel like I'd have to for-loop every folder in every sub-directory to make this work. I feel like I used to know the solution but my mush-brain can't retrieve it anymore.
https://redd.it/xl64tm
@r_bash
reddit
Symlink the contents of a directory, in to another, preserving...
Hi, I've been trying to figure this out for a while and my brain just hurts...like I've literally given myself a headache trying to figure this...
Script to change ECS tasks desireCount to 0 and then start it
Hi guys,
Since ECS services cant be stopped (tasks can) I need to write a noscript to place it inside a buildspec.yml which is also inside a Codepipeline. The noscripts need to grab an ECS service and update all its tasks with DesireCount 0 and then write another one, that replaces the DesireCount = 1
The idea is to have desirecount value, hardcoded on the noscript
So far I haves this
\# aws ecs update-service --desired-count 0 --cluster "ecs-my-ClusterName" --service "service-my-ServiceName-zxzxz"
#!/bin/bash
echo "Modify desire count"
for service in $(ecs_services); do
aws ecs update-service --cluster ${ecsClusterName} --service "$service" --desired-count 0 --no-cli-pager > /dev/null;
done
#Here comes the part to start tasks
Does it make any sense? Its been awhile since my last shell noscript
https://redd.it/xl63ma
@r_bash
Hi guys,
Since ECS services cant be stopped (tasks can) I need to write a noscript to place it inside a buildspec.yml which is also inside a Codepipeline. The noscripts need to grab an ECS service and update all its tasks with DesireCount 0 and then write another one, that replaces the DesireCount = 1
The idea is to have desirecount value, hardcoded on the noscript
So far I haves this
\# aws ecs update-service --desired-count 0 --cluster "ecs-my-ClusterName" --service "service-my-ServiceName-zxzxz"
#!/bin/bash
echo "Modify desire count"
for service in $(ecs_services); do
aws ecs update-service --cluster ${ecsClusterName} --service "$service" --desired-count 0 --no-cli-pager > /dev/null;
done
#Here comes the part to start tasks
Does it make any sense? Its been awhile since my last shell noscript
https://redd.it/xl63ma
@r_bash
reddit
Script to change ECS tasks desireCount to 0 and then start it
Hi guys, Since ECS services cant be stopped (tasks can) I need to write a noscript to place it inside a buildspec.yml which is also inside a...
New to bash with a simple question.
Say I’m already in a folder and just want to see all files that are 4 character long in the name. What command can do that?
https://redd.it/xladhp
@r_bash
Say I’m already in a folder and just want to see all files that are 4 character long in the name. What command can do that?
https://redd.it/xladhp
@r_bash
reddit
New to bash with a simple question.
Say I’m already in a folder and just want to see all files that are 4 character long in the name. What command can do that?
Working on browser agnostic bookmarks, shellcheck no help.
This seems to work fine.
https://paste.debian.net/1254702/
But shellcheck complains about
https://i.imgur.com/M3OoBmf.jpg
Ignore shellcheck? I mean it works as I want, I think. Haven't tested spaces in denoscription much, which I'd very much like to have, but it does seem to work as is.
https://redd.it/xlbtgc
@r_bash
This seems to work fine.
https://paste.debian.net/1254702/
But shellcheck complains about
egrep -o use grep -E instead. However if I do that any selection I make tries to open a local file. eg..https://i.imgur.com/M3OoBmf.jpg
Ignore shellcheck? I mean it works as I want, I think. Haven't tested spaces in denoscription much, which I'd very much like to have, but it does seem to work as is.
https://redd.it/xlbtgc
@r_bash
Bash Linkedin Skill Badge: Prepare for Skill Assessment and Get Badge on Your Profile
https://www.rbtechtips.com/linkedin-bash-assessment-answers-2022-bash-skill-badge/
https://redd.it/xlmkj3
@r_bash
https://www.rbtechtips.com/linkedin-bash-assessment-answers-2022-bash-skill-badge/
https://redd.it/xlmkj3
@r_bash
RBTechTips
LinkedIn Bash Assessment Answers 2022: Bash Skill Badge - RBTechTips
LinkedIn Bash Assessment Answers 2022: Bash Skill Badge: Bash LinkedIn Test Answers: In this post you will get all the correct answers of LinkedIn Bash quiz
how to validate options in noscript.
​
So I have noscript that takes file from user with option -y or -n and -d is required noscript runs ./example.sh -d file -y or -n variable. I made case getops "d:up" option`
​
Correct way running noscript: ./example.sh -d file -y or -n variable.
file="" -- that user inputs file
I need to do validation on if the user did not pass file in for example
./example.sh -y --- it should give error "must provide file"
./example.sh -d --- it should give error "must provide file"
./example.sh -y -n --- it should give error "must provide file"
i came up with this but its not working #checking if the file is provided
if $file -eq 1 ; then echo "No file provided"
exit 1
fi
# Does the file exist which works for checking if the file exists but it only check if the file in there
if [ ! -f $file ]; then
echo "Error: The file $file does not exist."
exit 1 fi
i already have validations for everything else but i need figure out how to make sure if the person doesnt provide file like examples above if gives out a error
https://redd.it/xm36mm
@r_bash
​
So I have noscript that takes file from user with option -y or -n and -d is required noscript runs ./example.sh -d file -y or -n variable. I made case getops "d:up" option`
​
Correct way running noscript: ./example.sh -d file -y or -n variable.
file="" -- that user inputs file
I need to do validation on if the user did not pass file in for example
./example.sh -y --- it should give error "must provide file"
./example.sh -n --- it should give error "must provide file" ./example.sh -d --- it should give error "must provide file"
./example.sh -y -n --- it should give error "must provide file"
i came up with this but its not working #checking if the file is provided
if $file -eq 1 ; then echo "No file provided"
exit 1
fi
# Does the file exist which works for checking if the file exists but it only check if the file in there
if [ ! -f $file ]; then
echo "Error: The file $file does not exist."
exit 1 fi
i already have validations for everything else but i need figure out how to make sure if the person doesnt provide file like examples above if gives out a error
https://redd.it/xm36mm
@r_bash
reddit
how to validate options in noscript.
So I have noscript that takes file from user with option -y or -n and -d is required noscript runs ./example.sh -d file -y or -n variable. I...