Any flaws in this noscript that could be potentially bad?
#!/bin/bash
# Check if three arguments are provided
if "$#" -ne 3 ; then
echo "Usage: $0 <begtime> <endtime> <logfilegzipped>"
exit 1
fi
beg=$1
end=$2
logfilegzipped=$3
function nongzipped() {
LCALL=C awk -v beg="$beg" -v end="$end" '
match($0, /0-20-9:0-50-9:0-50-9/) {
t = substr($0, RSTART, 8)
if (t >= end) selected = 0
else if (t >= beg) selected = 1
}
selected' "$logfilegzipped" #ignore the name lol
}
function gzipped() {
zcat "$logfilegzipped" | LCALL=C awk -v beg="$beg" -v end="$end" '
match($0, /[0-2][0-9]:[0-5][0-9]:[0-5][0-9]/) {
t = substr($0, RSTART, 8)
if (t >= end) selected = 0
else if (t >= beg) selected = 1
}
selected'
}
if [[ "$logfilegzipped" == *.gz ]]; then
gzipped
else
nongzipped
fi
I just modified this noscript that I wrote few months ago to accomodate both cases of gzipped and non gzipped log files. Any flaws with this you can notice. This works on my machine.
Any ways to make this better? Please don't post solutions. I'd have asked chatgpt but I like the journey in learning rather than getting answers quickly. Only correct me if there is serious flaw in this.
https://redd.it/1akbuj9
@r_bash
#!/bin/bash
# Check if three arguments are provided
if "$#" -ne 3 ; then
echo "Usage: $0 <begtime> <endtime> <logfilegzipped>"
exit 1
fi
beg=$1
end=$2
logfilegzipped=$3
function nongzipped() {
LCALL=C awk -v beg="$beg" -v end="$end" '
match($0, /0-20-9:0-50-9:0-50-9/) {
t = substr($0, RSTART, 8)
if (t >= end) selected = 0
else if (t >= beg) selected = 1
}
selected' "$logfilegzipped" #ignore the name lol
}
function gzipped() {
zcat "$logfilegzipped" | LCALL=C awk -v beg="$beg" -v end="$end" '
match($0, /[0-2][0-9]:[0-5][0-9]:[0-5][0-9]/) {
t = substr($0, RSTART, 8)
if (t >= end) selected = 0
else if (t >= beg) selected = 1
}
selected'
}
if [[ "$logfilegzipped" == *.gz ]]; then
gzipped
else
nongzipped
fi
I just modified this noscript that I wrote few months ago to accomodate both cases of gzipped and non gzipped log files. Any flaws with this you can notice. This works on my machine.
Any ways to make this better? Please don't post solutions. I'd have asked chatgpt but I like the journey in learning rather than getting answers quickly. Only correct me if there is serious flaw in this.
https://redd.it/1akbuj9
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Any better solutions than this one?
https://redd.it/1akuntp
@r_bash
print_progress(){
local progress_msg="${1}"; shift
local separator_string=
for ((i = 0; i < COLUMNS; i = i + 1)); do
separator_string+='='
done
printf '\n%s\n%s\n%s\n' \
"${separator_string}" \
"${progress_msg}" \
"${separator_string}"
}
print_progress 'Currently doing blablabla...'
https://redd.it/1akuntp
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Help with noscript - creating a 'simple' compose file on remote server via ssh
I run a bash noscript on my local pc. Its configures a remote server by ssh, adding users, installing docker etc. Theres a part in it that writes and then runs a traefik compose file but there is a line in it that bash doent seem to like:
\- "traefik.http.routers.api.rule=Host(`website.com`)"
It ends up writing the line:
\- "traefik.http.routers.api.rule=Host()"
This causes the container to fail.
​
Ive even tried (unsuccessfully) writing the file with commands such as:
printf '%s\\n' " - traefik.http.routers.api.rule=Host('website.com')"
​
How do i get round this problem. GPT is looping on me and getting nowhere. Part of my noscript:
​
su - bob -c "
\# Create and write to the file
cat > docker-compose_traefik.yml << 'EOF'
version: "3.3"
​
services:
traefik:
image: traefik:v3.0
restart: always
container_name: traefik
ports:
\- "80:80"
\- "8080:8080"
\- "443:443"
command:
\- --api.insecure=true
\- --api.dashboard=true
\- --api.debug=true
\- --log.level=DEBUG
\- --providers.docker=true
\- --providers.docker.exposedbydefault=false
\- --providers.file.filename=/dynamic.yaml
\- --providers.docker.network=web
\- --entrypoints.web.address=:80
volumes:
\- /var/run/docker.sock:/var/run/docker.sock
\- ./dynamic.yaml:/dynamic.yaml
networks:
\- web
labels:
\- "traefik.enable=true"
\- "traefik.http.routers.api.rule=Host(`website.com`)"
\- "traefik.http.routers.api.service=api@internal" access
​
networks:
web:
external: true
EOF
​
https://redd.it/1akyrk4
@r_bash
I run a bash noscript on my local pc. Its configures a remote server by ssh, adding users, installing docker etc. Theres a part in it that writes and then runs a traefik compose file but there is a line in it that bash doent seem to like:
\- "traefik.http.routers.api.rule=Host(`website.com`)"
It ends up writing the line:
\- "traefik.http.routers.api.rule=Host()"
This causes the container to fail.
​
Ive even tried (unsuccessfully) writing the file with commands such as:
printf '%s\\n' " - traefik.http.routers.api.rule=Host('website.com')"
​
How do i get round this problem. GPT is looping on me and getting nowhere. Part of my noscript:
​
su - bob -c "
\# Create and write to the file
cat > docker-compose_traefik.yml << 'EOF'
version: "3.3"
​
services:
traefik:
image: traefik:v3.0
restart: always
container_name: traefik
ports:
\- "80:80"
\- "8080:8080"
\- "443:443"
command:
\- --api.insecure=true
\- --api.dashboard=true
\- --api.debug=true
\- --log.level=DEBUG
\- --providers.docker=true
\- --providers.docker.exposedbydefault=false
\- --providers.file.filename=/dynamic.yaml
\- --providers.docker.network=web
\- --entrypoints.web.address=:80
volumes:
\- /var/run/docker.sock:/var/run/docker.sock
\- ./dynamic.yaml:/dynamic.yaml
networks:
\- web
labels:
\- "traefik.enable=true"
\- "traefik.http.routers.api.rule=Host(`website.com`)"
\- "traefik.http.routers.api.service=api@internal" access
​
networks:
web:
external: true
EOF
​
https://redd.it/1akyrk4
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Code review request
I tested the program on 5 machines running on matic 23.10 and cant find any issues. Would like to know if there are any issues with the code. As code is broken down into many functions i cant upload snippets here.
I would like reviewers to point to memory_init function which is an odd ball in the whole hierarchy.
Here is the link.
https://github.com/ioprojecton/CPU-Y
Thanks.
https://redd.it/1al1lw9
@r_bash
I tested the program on 5 machines running on matic 23.10 and cant find any issues. Would like to know if there are any issues with the code. As code is broken down into many functions i cant upload snippets here.
I would like reviewers to point to memory_init function which is an odd ball in the whole hierarchy.
Here is the link.
https://github.com/ioprojecton/CPU-Y
Thanks.
https://redd.it/1al1lw9
@r_bash
GitHub
GitHub - ioprojecton/CPU-Y: System info for Ubuntu
System info for Ubuntu. Contribute to ioprojecton/CPU-Y development by creating an account on GitHub.
Issue with a simple Bash Script for adding an iRule to a list of Virtual Servers.
Hello Community,
I am quite new to Bash noscripting. Though I know the platform I intend the noscript to run on is not relevant to this sub, I would appreciate if you could at least elevate my concern that the problem I am encountering is with my Bash noscript itself and not the environment I'm running it on.
I am having an issue with a bash noscript for an F5 BIG-IP Load Balancer which is intended to:
1. Take as input a .txt file named "vs_list.txt" containing a list of Virtual Server Names, each on a separate row.
2. Prompt the user for the name of the iRule that needs to be added to the Virtual Servers.
3. Iterate over the VS Names from the input list and retreives the partition in which each VS resides (building on F5 Support Solution K59493724: How to get details of the virtual servers in all partitions via TMSH? (https://my.f5.com/manage/s/article/K59493724))
4. Checks for and retrevies the iRules which are currently configured for the given VS# Adds the new iRule to the given VS and coserves pre-existing iRules if any.
When running the noscript I am only hitting the outermost 'else' statement for being unable to find the partition and VS name.
#!/bin/bash
# Prompt the user for the iRule name and read it into the 'new' variable
echo "Please enter the iRule name:"
read new
noneRules='rules none'
while IFS= read -r vsname; do
# Retrieve the partition and virtual server name
fullvsinfo=$(tmsh -c "cd /; list ltm virtual recursive" | grep "$vsname" | grep -m1 "^ltm virtual")
echo "Full VS Info Debug: $fullvsinfo"
# Extract the partition and virtual server name from the retrieved information
if [ $full_vs_info =~ ltm\ virtual\ (.+)/(.+) ]; then
partition="${BASHREMATCH[1]}"
vsname="${BASHREMATCH[2]}"
# Format the tmsh command to include the partition
rule=$(tmsh list ltm virtual /$partition/$vsname rules | egrep -v "\{|\}" | xargs)
if [ "$rule" == "$noneRules" ]; then
tmsh modify ltm virtual /$partition/$vsname rules { $new }
echo "iRule $new was added to $vsname in partition $partition"
else#
tmsh modify ltm virtual /$partition/$vsname rules { $rule $new }
echo "iRules $rule were conserved and added $new to $vsname in partition $partition"
fi
else
echo "Could not find partition and virtual server name for $vsname"
fi
done < /shared/tmp/testlist.txt
tmsh save sys config
As far as I was able to troubleshoot, the problem I am encountering appears to be with line 11 of my noscript where I attempt to assign the string "ltm virtual SomePartition/VS_Example.com {" to the "full_vs_info" variable using:
full_vs_info=$(tmsh -c "cd /; list ltm virtual recursive" | grep "$vs_name" | grep -m1 "\^ltm virtual")
When I run the tmsh command [tmsh -c "cd /; list ltm virtual recursive" | grep "VS_Example.com" | grep -m1 "\^ltm virtual"\] on its own, from the F5's Bash shell, I am getting the output I expect:
"ltm virtual SomePartition/VS_Example.com {"
However, when I run the noscript with the debug echo , it only outputs "Full VS Info Debug:", and ends the noscript with "Could not find partition and virtual server name for $vs_name" and a sys config save.
If at all relevant, I am attempting to run this on a BIG-IP, version (https://15.1.10.2), build 0.44.2.
All feedback and criticism is highly appreciated! Thanks in advance!
https://redd.it/1al6h61
@r_bash
Hello Community,
I am quite new to Bash noscripting. Though I know the platform I intend the noscript to run on is not relevant to this sub, I would appreciate if you could at least elevate my concern that the problem I am encountering is with my Bash noscript itself and not the environment I'm running it on.
I am having an issue with a bash noscript for an F5 BIG-IP Load Balancer which is intended to:
1. Take as input a .txt file named "vs_list.txt" containing a list of Virtual Server Names, each on a separate row.
2. Prompt the user for the name of the iRule that needs to be added to the Virtual Servers.
3. Iterate over the VS Names from the input list and retreives the partition in which each VS resides (building on F5 Support Solution K59493724: How to get details of the virtual servers in all partitions via TMSH? (https://my.f5.com/manage/s/article/K59493724))
4. Checks for and retrevies the iRules which are currently configured for the given VS# Adds the new iRule to the given VS and coserves pre-existing iRules if any.
When running the noscript I am only hitting the outermost 'else' statement for being unable to find the partition and VS name.
#!/bin/bash
# Prompt the user for the iRule name and read it into the 'new' variable
echo "Please enter the iRule name:"
read new
noneRules='rules none'
while IFS= read -r vsname; do
# Retrieve the partition and virtual server name
fullvsinfo=$(tmsh -c "cd /; list ltm virtual recursive" | grep "$vsname" | grep -m1 "^ltm virtual")
echo "Full VS Info Debug: $fullvsinfo"
# Extract the partition and virtual server name from the retrieved information
if [ $full_vs_info =~ ltm\ virtual\ (.+)/(.+) ]; then
partition="${BASHREMATCH[1]}"
vsname="${BASHREMATCH[2]}"
# Format the tmsh command to include the partition
rule=$(tmsh list ltm virtual /$partition/$vsname rules | egrep -v "\{|\}" | xargs)
if [ "$rule" == "$noneRules" ]; then
tmsh modify ltm virtual /$partition/$vsname rules { $new }
echo "iRule $new was added to $vsname in partition $partition"
else#
tmsh modify ltm virtual /$partition/$vsname rules { $rule $new }
echo "iRules $rule were conserved and added $new to $vsname in partition $partition"
fi
else
echo "Could not find partition and virtual server name for $vsname"
fi
done < /shared/tmp/testlist.txt
tmsh save sys config
As far as I was able to troubleshoot, the problem I am encountering appears to be with line 11 of my noscript where I attempt to assign the string "ltm virtual SomePartition/VS_Example.com {" to the "full_vs_info" variable using:
full_vs_info=$(tmsh -c "cd /; list ltm virtual recursive" | grep "$vs_name" | grep -m1 "\^ltm virtual")
When I run the tmsh command [tmsh -c "cd /; list ltm virtual recursive" | grep "VS_Example.com" | grep -m1 "\^ltm virtual"\] on its own, from the F5's Bash shell, I am getting the output I expect:
"ltm virtual SomePartition/VS_Example.com {"
However, when I run the noscript with the debug echo , it only outputs "Full VS Info Debug:", and ends the noscript with "Could not find partition and virtual server name for $vs_name" and a sys config save.
If at all relevant, I am attempting to run this on a BIG-IP, version (https://15.1.10.2), build 0.44.2.
All feedback and criticism is highly appreciated! Thanks in advance!
https://redd.it/1al6h61
@r_bash
F5
How to get details of the virtual servers in all partitions via TMSH?
Denoscription
You would like to get the details of your virtual servers in all partitions and sub-folders using TMSH. Environment BIG-IP LTM Virtual Servers TMSH Partitions Sub-folders Cause
None Recommended Actions Option 1 You can use the following command…
You would like to get the details of your virtual servers in all partitions and sub-folders using TMSH. Environment BIG-IP LTM Virtual Servers TMSH Partitions Sub-folders Cause
None Recommended Actions Option 1 You can use the following command…
Responsive image gallery in three lines of bash
Three lines of bash to generate a responsive HTML image gallery — motivated by having to spend way too much time on getting /r/immich and /r/photoprism to do what I wanted them to do... both are awesome projects btw.
>❗️NOTE: on MacOS this requires the GNU flavour of
echo '<html><head><style>img {max-width: 321px; height: auto; display: table-cell;} body>div {display: grid; grid-template-columns: repeat(auto-fill, minmax(321px, 1fr)); gap: 5px;}</style></head><body><div>' > gallery.html
find -type f ! -name '.*' -a -iregex '.*\.\(jpg\|jpeg\|png\|noscript\|bmp\|webp\|gif\)' -printf '<a href="%P" target="blank" noscript="%P size: %s bytes; created: %c"><img src="%P" loading="lazy"></a>\n' >> gallery.html
echo '</div></body></html>' >> gallery.html
(the only reason I did not extract
https://redd.it/1amkg1n
@r_bash
Three lines of bash to generate a responsive HTML image gallery — motivated by having to spend way too much time on getting /r/immich and /r/photoprism to do what I wanted them to do... both are awesome projects btw.
>❗️NOTE: on MacOS this requires the GNU flavour of
find — use brew install findutils and replace in the noscript find with gfind.echo '<html><head><style>img {max-width: 321px; height: auto; display: table-cell;} body>div {display: grid; grid-template-columns: repeat(auto-fill, minmax(321px, 1fr)); gap: 5px;}</style></head><body><div>' > gallery.html
find -type f ! -name '.*' -a -iregex '.*\.\(jpg\|jpeg\|png\|noscript\|bmp\|webp\|gif\)' -printf '<a href="%P" target="blank" noscript="%P size: %s bytes; created: %c"><img src="%P" loading="lazy"></a>\n' >> gallery.html
echo '</div></body></html>' >> gallery.html
(the only reason I did not extract
gallery.html to a variable was to keep it to 3 lines)https://redd.it/1amkg1n
@r_bash
Reddit
Immich
High performance self-hosted photo and video management solution
What do you call the '-' when used to specify options (like set -x)?
View Poll
https://redd.it/1amlbbo
@r_bash
View Poll
https://redd.it/1amlbbo
@r_bash
Invoke bash noscript in remote server
I'm running a noscript from my jump host to copy a noscript to client servers. From that copied noscript will run on the client server and check for a specific agent is installed or not. If not it will install through that noscript. But before installation happen I want to raise a standard change servicenow.
Standard change raising noscript also in the jumphost. That only can be run from the jumphost.
So I want to know how can we invoke standard change raising noscript with parsing some information to that from the client machine,
https://redd.it/1amqbf8
@r_bash
I'm running a noscript from my jump host to copy a noscript to client servers. From that copied noscript will run on the client server and check for a specific agent is installed or not. If not it will install through that noscript. But before installation happen I want to raise a standard change servicenow.
Standard change raising noscript also in the jumphost. That only can be run from the jumphost.
So I want to know how can we invoke standard change raising noscript with parsing some information to that from the client machine,
https://redd.it/1amqbf8
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Dynamic FFmpeg build noscript
This builds the latest stable release version series 6 of FFmpeg with additional codecs included.
This will dynamically find the latest source code for each codec and update them accordingly.
I am slowly working on a GNU version of this noscript that will allow the user to specify a GNU all build so check back over time.
As always I hope some of you guys find this useful.
Cheers
​
Lit of codecs available
GitHub Script
https://redd.it/1ao2csh
@r_bash
This builds the latest stable release version series 6 of FFmpeg with additional codecs included.
This will dynamically find the latest source code for each codec and update them accordingly.
I am slowly working on a GNU version of this noscript that will allow the user to specify a GNU all build so check back over time.
As always I hope some of you guys find this useful.
Cheers
​
Lit of codecs available
GitHub Script
https://redd.it/1ao2csh
@r_bash
Shell noscript that can add bookmarked directories and cd into them directly (+video)
Hi all. I was getting tired of writing long cd commands to get to specific directories in the terminal. I found there were some programs/tricks for this (like CDPATH) but none of them worked for me. Hence, I made a small shell noscript that can add/delete/navigate bookmarked directories. Thank you!
You can watch a 2 minute demo here: Loom video
Or view the source code here: https://github.com/TimoKats/CDBookmark/
https://redd.it/1ao5lob
@r_bash
Hi all. I was getting tired of writing long cd commands to get to specific directories in the terminal. I found there were some programs/tricks for this (like CDPATH) but none of them worked for me. Hence, I made a small shell noscript that can add/delete/navigate bookmarked directories. Thank you!
You can watch a 2 minute demo here: Loom video
Or view the source code here: https://github.com/TimoKats/CDBookmark/
https://redd.it/1ao5lob
@r_bash
Loom
Script for Bookmarking Directories in Linux
In this video, I demonstrate a noscript that allows you to bookmark directories in your file system, making it easy to navigate to them from anywhere. I show you how to add, list, delete, and go to bookmarks using the noscript. I also explain how to set up the…
GREP - Practical Guide 🚀
Last month, I discovered one of the best terminal commands. And wrote a blog about it here - https://www.priya.today/blogs/grep
Can you share some useful tips and tricks?
I would greatly appreciate your feedback.
https://redd.it/1ao6dfz
@r_bash
Last month, I discovered one of the best terminal commands. And wrote a blog about it here - https://www.priya.today/blogs/grep
Can you share some useful tips and tricks?
I would greatly appreciate your feedback.
https://redd.it/1ao6dfz
@r_bash
Priya's blog
GREP - Practical Guide 🚀
Grep is a terminal command that allows users to search for specific patterns within text files and directories.
Anyone handle piping ?
What command line can I use to read an output from piping: "cat this.txt | xargs echo" show me a string with spaces like this "123 156 856 899". But into this.txt have next line.
I need to grab one to one that elements before spaces in the next piping command line using xargs or another commmand line.
Thanks.
https://redd.it/1aob81w
@r_bash
What command line can I use to read an output from piping: "cat this.txt | xargs echo" show me a string with spaces like this "123 156 856 899". But into this.txt have next line.
I need to grab one to one that elements before spaces in the next piping command line using xargs or another commmand line.
Thanks.
https://redd.it/1aob81w
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Using SORT but ignore "the", "a" and "an"?
As the noscript says...
I have list of noscripts. I want to sort the list, but I don't want all the noscripts starting with "the" bunch together.
I read through the man page hoping to find a way to get SORT to ignore a word, but I ran dry.
Anyone have any ideas?
https://redd.it/1aod18i
@r_bash
As the noscript says...
I have list of noscripts. I want to sort the list, but I don't want all the noscripts starting with "the" bunch together.
I read through the man page hoping to find a way to get SORT to ignore a word, but I ran dry.
Anyone have any ideas?
https://redd.it/1aod18i
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Please give me pointers on how to make my watermark noscript suck less
#!/bin/bash
# First, a file to work on is picked
echo "Which file to work on?"
read -e "filetoworkon"
# Then, the format to convert to is chosen:
# 1) 13x18cm (2126px wide)
# 2) 18x13cm (942px wide)
read -n1 -p "Pick 1) for 18x13 or 2) for 13x18 1,2" doit
case $doit in
1) convert "$filetoworkon" -resize 2126 "$filetoworkon"-resized.png ;;
2) convert "$filetoworkon" -resize 492 "$filetoworkon"-resized.png ;;
) echo dont know ;;
esac
# Then the file to use as a watermark is chosen
echo "Which file to use as watermark?"
# A list of options is given
echo "Options:"
ls my-logo-.pdf
read -e "watermarkfile"
# Finally, the watermark is added
convert "$filetoworkon"-resized.png "$watermarkfile" +distort affine "0,0 0,0 %w,%h %fx:t?v.w*(u.h/v.h*0.05):s.w,%fx:t?v.h*(u.h/v.h*0.05):s.h" -shave 1 -gravity southeast -geometry +50+50 -compose hard-light -composite "$filetoworkon"-resized-signed.png
echo ""File saved as "$filetoworkon"-resized-signed.png""
It does what it has to, but it is ugly and there is some redundancy. I've also been told that I should use functions instead of
​
I hope someone will help me clean up this thing, and explain how it could be improved.
https://redd.it/1aosyju
@r_bash
#!/bin/bash
# First, a file to work on is picked
echo "Which file to work on?"
read -e "filetoworkon"
# Then, the format to convert to is chosen:
# 1) 13x18cm (2126px wide)
# 2) 18x13cm (942px wide)
read -n1 -p "Pick 1) for 18x13 or 2) for 13x18 1,2" doit
case $doit in
1) convert "$filetoworkon" -resize 2126 "$filetoworkon"-resized.png ;;
2) convert "$filetoworkon" -resize 492 "$filetoworkon"-resized.png ;;
) echo dont know ;;
esac
# Then the file to use as a watermark is chosen
echo "Which file to use as watermark?"
# A list of options is given
echo "Options:"
ls my-logo-.pdf
read -e "watermarkfile"
# Finally, the watermark is added
convert "$filetoworkon"-resized.png "$watermarkfile" +distort affine "0,0 0,0 %w,%h %fx:t?v.w*(u.h/v.h*0.05):s.w,%fx:t?v.h*(u.h/v.h*0.05):s.h" -shave 1 -gravity southeast -geometry +50+50 -compose hard-light -composite "$filetoworkon"-resized-signed.png
echo ""File saved as "$filetoworkon"-resized-signed.png""
It does what it has to, but it is ugly and there is some redundancy. I've also been told that I should use functions instead of
read -e, but I don't know how. ​
I hope someone will help me clean up this thing, and explain how it could be improved.
https://redd.it/1aosyju
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Move to new $ line
I need to move to a directory, move to a new line and execute a noscript.
user@ubuntu:\~$ mynoscript
user@ubuntu:\~/Documents$ server started on port 3000
Right now my noscript executes like this
user@ubuntu:\~$ server started on port 3000
​
https://redd.it/1aox1kr
@r_bash
I need to move to a directory, move to a new line and execute a noscript.
user@ubuntu:\~$ mynoscript
user@ubuntu:\~/Documents$ server started on port 3000
Right now my noscript executes like this
user@ubuntu:\~$ server started on port 3000
​
https://redd.it/1aox1kr
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
I can't understand the result. bad string to variable assignment.
if I run:
# as expected result:
text "https://dl.discordapp.net/apps/linux/0.0.43/discord-0.0.43.deb"
but,
or
# strange result:
"ext "https://dl.discordapp.net/apps/linux/0.0.43/discord-0.0.43.deb
the first letter of 'text' is removed: 'ext'.
the double quotes are moved to the first token instead of covering up the URL.
I don't know how to explain it, I don't know how to research it, I have no idea what the problem is or how to solve it.
thx _o/
https://redd.it/1apetnl
@r_bash
if I run:
URL=https://dl.discordapp.net/apps/linux/0.0.43/discord-0.0.43.deb; echo "text \"$URL\"";# as expected result:
text "https://dl.discordapp.net/apps/linux/0.0.43/discord-0.0.43.deb"
but,
URL=$(curl -Is -- 'https://discord.com/api/download/stable?platform=linux&format=deb' | grep -i 'location' | awk '{print $2}'); echo "text \"$URL\"";or
URL=$(curl -Is -- 'https://discord.com/api/download/stable?platform=linux&format=deb' | grep -i 'location' | cut -d' ' -f2); echo "text \"$URL\"";# strange result:
"ext "https://dl.discordapp.net/apps/linux/0.0.43/discord-0.0.43.deb
the first letter of 'text' is removed: 'ext'.
the double quotes are moved to the first token instead of covering up the URL.
I don't know how to explain it, I don't know how to research it, I have no idea what the problem is or how to solve it.
thx _o/
https://redd.it/1apetnl
@r_bash
Script acts differently when called with sh compared to bash
Weird noscript but bear with me.
​
So I have a noscript that fails on machines when called without specifying bash. The noscript ultimately does the below as an example.
​
mynoscript
#!/bin/bash
#
#
#
searchPath=/opt/folder/files/
player < ${searchPath}/music.mp3
When I call the noscript as /bin/mynoscript, i fails with "No such file or directory" and does not appear to expand the \ as a wildcard. If I call it as "bash /bin/mynoscript" it functions correctly and handles the wildcard.
​
Any thoughts on why it fails unless I specify "bash" even though there is a shebang/execute bits?
https://redd.it/1aphmz7
@r_bash
Weird noscript but bear with me.
​
So I have a noscript that fails on machines when called without specifying bash. The noscript ultimately does the below as an example.
​
mynoscript
#!/bin/bash
#
#
#
searchPath=/opt/folder/files/
player < ${searchPath}/music.mp3
When I call the noscript as /bin/mynoscript, i fails with "No such file or directory" and does not appear to expand the \ as a wildcard. If I call it as "bash /bin/mynoscript" it functions correctly and handles the wildcard.
​
Any thoughts on why it fails unless I specify "bash" even though there is a shebang/execute bits?
https://redd.it/1aphmz7
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How to get realtime output from bash
Have a noscript that runs a custom program within bash, the exe takes a while to run, about 5 minutes, but when you run it there are heartbeats printed to let the user know that it is still running, on my bash, those messages appear after the noscript has finished running, also, it seems the buffer is full and not every message gets printed, I tried redirecting to a file but still the output is not "real time"
something like
# !/bin/bash
testexecutable --flag=1 | tee "/tmp/testoutput.txt"
this is on macos, also tried to output to /dev/tty but it says its not configured.
https://redd.it/1apk4hq
@r_bash
Have a noscript that runs a custom program within bash, the exe takes a while to run, about 5 minutes, but when you run it there are heartbeats printed to let the user know that it is still running, on my bash, those messages appear after the noscript has finished running, also, it seems the buffer is full and not every message gets printed, I tried redirecting to a file but still the output is not "real time"
something like
# !/bin/bash
testexecutable --flag=1 | tee "/tmp/testoutput.txt"
this is on macos, also tried to output to /dev/tty but it says its not configured.
https://redd.it/1apk4hq
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Why does "cat | ls" behave like that?
Hello everyone,
I am doing a project that consists on replicating bash (some of its basic behavior) in C.
I am still on the early stages of the project, analyzing how bash behaves with different inputs.
The point is that I was playing with some basic commands and its combinations through pipe (|) operator, and when I tried "cat | ls" I was kind of expecting just the ouput of ls, but instead got:
bash-4.4$ cat | ls
file1 file2 file3
And it just holds there awaiting for input. Then after just enter it stop the execution with a result of:
bash-4.4$ cat | ls
file1 file2 file3
bash-4.4$
It feel like bash its prioritizing ls over cat, does anyone know what is going on underneath?
Thanks!
https://redd.it/1apxpef
@r_bash
Hello everyone,
I am doing a project that consists on replicating bash (some of its basic behavior) in C.
I am still on the early stages of the project, analyzing how bash behaves with different inputs.
The point is that I was playing with some basic commands and its combinations through pipe (|) operator, and when I tried "cat | ls" I was kind of expecting just the ouput of ls, but instead got:
bash-4.4$ cat | ls
file1 file2 file3
And it just holds there awaiting for input. Then after just enter it stop the execution with a result of:
bash-4.4$ cat | ls
file1 file2 file3
bash-4.4$
It feel like bash its prioritizing ls over cat, does anyone know what is going on underneath?
Thanks!
https://redd.it/1apxpef
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community