Help improve my noscript
Hi there,
Intro:
fairly new to shell noscripting and I came up with this (after many searches and much rtfming) noscript to automate my openconnect vpn server selection and connecting. Basically what it does is that it pings each server and the using awk take out the average speed of each server then tests to see which server is faster and connects to it.
Question:
I dont think I did such a good job in that if statement and overall I think the noscript is kinda nasty.
How can I make it better and more professional?
Should I have used a fore loop? (cause I couldnt make it work)
Thanks to everyone who spends their time reading and helping a newbie :)
The Script:
PS: It works but I still am not so sure if the test is done right
https://redd.it/zaxkm4
@r_bash
Hi there,
Intro:
fairly new to shell noscripting and I came up with this (after many searches and much rtfming) noscript to automate my openconnect vpn server selection and connecting. Basically what it does is that it pings each server and the using awk take out the average speed of each server then tests to see which server is faster and connects to it.
Question:
I dont think I did such a good job in that if statement and overall I think the noscript is kinda nasty.
How can I make it better and more professional?
Should I have used a fore loop? (cause I couldnt make it work)
Thanks to everyone who spends their time reading and helping a newbie :)
The Script:
#!/usr/bin/env bash
# Test the ping of kerio servers and select the one with the lowest ping
# VARs
SERV1=$(ping -c 4 c1.kmak.us | tail -1| awk -F '/' '{print $5}')
SERV2=$(ping -c 4 c2.kmak.us | tail -1| awk -F '/' '{print $5}')
SERV3=$(ping -c 4 c3.kmak.us | tail -1| awk -F '/' '{print $5}')
SERV4=$(ping -c 4 hdk.csw5.kmak.xyz | tail -1| awk -F '/' '{print $5}')
SERV5=$(ping -c 4 sja.c24.kmak.xyz | tail -1| awk -F '/' '{print $5}')
SERV6=$(ping -c 4 wen.c25.kmak.xyz | tail -1| awk -F '/' '{print $5}')
# Connecting VARs
CMD1=$(echo "password" | doas openconnect c1.kmak.us:443 --user=xm --passwd-on-stdin)
CMD2=$(echo "password" | doas openconnect c2.kmak.us:443 --user=xm --passwd-on-stdin)
CMD3=$(echo "password" | doas openconnect c3.kmak.us:443 --user=xm --passwd-on-stdin)
CMD4=$(echo "password" | doas openconnect hdk.csw5.kmak.xyz --user=xm --passwd-on-stdin)
CMD5=$(echo "password" | doas openconnect sja.c24.kmak.xyz --user=xm --passwd-on-stdin)
CMD6=$(echo "password" | doas openconnect wen.c25.kmak.xyz --user=xm --passwd-on-stdin)
# Test
if (( $(echo "$SERV1 < $SERV2" | bc -l) )) && (( $(echo "$SERV1 < $SERV3" | bc -l) )); then
echo "$CMD1"
elif (( $(echo "$SERV2 < $SERV1" | bc -l) )) && (( $(echo "$SERV2 < $SERV3" | bc -l) )); then
echo "$CMD2"
elif (( $(echo "$SERV4 < $SERV5" | bc -l) )) && (( $(echo "$SERV4 < $SERV6" | bc -l) )); then
echo "$CMD4"
elif (( $(echo "$SERV5 < $SERV4" | bc -l) )) && (( $(echo "$SERV5 < $SERV6" | bc -l) )); then
echo "$CMD5"
elif (( $(echo "$SERV3 < $SERV6" | bc -l) )); then
echo "$CMD3"
elif (( $(echo "$SERV6 < $SERV3" | bc -l) )); then
echo "$CMD6"
else
echo "failiure in server resolve"
fi
PS: It works but I still am not so sure if the test is done right
https://redd.it/zaxkm4
@r_bash
reddit
Help improve my noscript
Hi there, Intro: fairly new to shell noscripting and I came up with this (after many searches and much rtfming) noscript to automate my openconnect...
Why trailing space always present after running my function?
Hello! I have the following function:
parse_see_also_links() {
declare line="$1"
echo "$line" |\
sed --regexp-extended "s/^> See also: *(.+) *\.\$/[\1]/; s/ +/ /g;"
}
For `parse_see_also_links "> See also: vim emacs ."` I wanna get `[vim emacs]` and not `[vim emacs ]`. How to fix code not to get the last space?
https://redd.it/zb7j17
@r_bash
Hello! I have the following function:
parse_see_also_links() {
declare line="$1"
echo "$line" |\
sed --regexp-extended "s/^> See also: *(.+) *\.\$/[\1]/; s/ +/ /g;"
}
For `parse_see_also_links "> See also: vim emacs ."` I wanna get `[vim emacs]` and not `[vim emacs ]`. How to fix code not to get the last space?
https://redd.it/zb7j17
@r_bash
reddit
Why trailing space always present after running my function?
Hello! I have the following function: parse_see_also_links() { declare line="$1" echo "$line" |\ sed --regexp-extended...
Advent of Code
Anyone else doing Advent of Code in BASH? I just finished day 3 with pure BASH. And I'm looking for more coding buddies to compare code, learn, challenge each other, share/contribute to other's projects or just bs. I have a small Discord channel with a group of programming buddies, where our goal is the above. A place to learn, share, compete, grow, etc. Join the Discord if you're interested — Open Source Force
https://redd.it/zbbshf
@r_bash
Anyone else doing Advent of Code in BASH? I just finished day 3 with pure BASH. And I'm looking for more coding buddies to compare code, learn, challenge each other, share/contribute to other's projects or just bs. I have a small Discord channel with a group of programming buddies, where our goal is the above. A place to learn, share, compete, grow, etc. Join the Discord if you're interested — Open Source Force
https://redd.it/zbbshf
@r_bash
Discord
Join the Open Source Force Discord Server!
Check out the Open Source Force community on Discord - hang out with 130 other members and enjoy free voice and text chat.
Help with regex, I think?
Here is what I'm working with so far:
If I run this as-is, I get output with the duplicate games listed twice (
Ultimately I'm trying to build .cfg files with one-or-more .png's defined for each one, but right now I'm still trying to get a unique list of game names.
The ending config files would look such as --
The only thing it needs to do is count the PNG's and list them -- the
https://redd.it/zbbn0k
@r_bash
Here is what I'm working with so far:
#!/bin/bash
# 1942_stu_ovl.png
# 1942_udb_ovl.png
# 1943_stu_ovl.png
# 19xx_bp_ovl.png
# 2020bb_bp_ovl.png
# 3wonders_bp_ovl.png
# aerofgt_bp_ovl.png
# airbustr_bp_ovl.png
# aliensec_bp_ovl.png
# aliens_udb23_nono6493_edit_ovl.png
games=()
while read -r png; do
game="$(basename "${png%%_*}")"
# [[ "$game" =~ ${games[*]} ]] || \
games+=("$game")
done < <(find . -type f -name "*.png" | sort -u)
echo "${games[@]}"
If I run this as-is, I get output with the duplicate games listed twice (
1942 1942 1943 (...) xybots zaxxon zaxxon). If I uncomment the [[ "$game" =~ ${games[*]} ]] || \ line, I get no output at all. What I want is each game listed once (1942 1943 19xx (...) xevious xybots zaxxon).Ultimately I'm trying to build .cfg files with one-or-more .png's defined for each one, but right now I'm still trying to get a unique list of game names.
The ending config files would look such as --
zaxxon_ovl.cfg:overlays = 3
overlay0_overlay = "./zaxxon_bp_ovl.png"
overlay0_full_screen = true
overlay0_descs = 0
overlay1_overlay = "./zaxxon_stu_ovl.png"
overlay1_full_screen = true
overlay1_descs = 0
overlay2_overlay = "./zaxxon_udb_ovl.png"
overlay2_full_screen = true
overlay2_descs = 0
The only thing it needs to do is count the PNG's and list them -- the
full_screen and descs values are always constant. Any ideas?https://redd.it/zbbn0k
@r_bash
reddit
Help with regex, I think?
Here is what I'm working with so far: ``` #!/bin/bash # 1942_stu_ovl.png # 1942_udb_ovl.png # 1943_stu_ovl.png # 19xx_bp_ovl.png #...
what this shell command mean: wait $${!} ?
Hello, I found this line of shell noscript in a docker-compose file.
Could you guys explain me what it does? I know it overrides the default CMD used in the Nginx Dockerfile to start the Nginx server and I know its purpose is to wait for another service called "certbot" that generates and signs certicates thanks to Letsencrypt and saves these certs in a shared folder
The docker-compose file in question:
Thanks you !
https://redd.it/zbj15f
@r_bash
Hello, I found this line of shell noscript in a docker-compose file.
/bin/sh -c 'while :; do sleep 36000 & wait $${!}; nginx -s reload; done & nginx -g \\"daemon off;\\"'
Could you guys explain me what it does? I know it overrides the default CMD used in the Nginx Dockerfile to start the Nginx server and I know its purpose is to wait for another service called "certbot" that generates and signs certicates thanks to Letsencrypt and saves these certs in a shared folder
/etc/certache/certs. But I dont see how ? especially I dont understand those characters : $${!}The docker-compose file in question:
/////////
web:
image: nginx:1.23
container_name: nginx
restart: always
ports:
- 80:8080
- 443:8443
volumes:
- ./nginx-templates:/etc/nginx/templates
- ./certcache/certs:/etc/certcache/certs:ro
environment:
- NGINX_HOST=${DOMAIN_NAME}
- PMA_HOST=phpmyadmin
command: "/bin/sh -c 'while :; do sleep 36000 & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
depends_on:
- phpmyadmin
- certcache
//////
Thanks you !
https://redd.it/zbj15f
@r_bash
reddit
what this shell command mean: wait $${!} ?
Hello, I found this line of shell noscript in a docker-compose file. ```bash /bin/sh -c 'while :; do sleep 36000 & wait $${!}; nginx -s reload;...
Need help with parameter expansions in my CLI tool.
I'm trying to debug my CLI tool ([https://github.com/membersincewayback/gen](https://github.com/membersincewayback/gen)) and address unset variables, however I just realized one of my parameter expansions isn't working how I thought it was supposed to as below:
#!/usr/bin/env bash
FILENAME="${!#}"
EXT="${FILENAME##*.}"
The intention is to set `FILENAME` to the last argument (working) and `EXT` to anything following the final "." (not working as expected). The problem is, if there is no "." it sets `EXT` == `FILENAME` which has undesired effects on the rest of the noscript. (i.e. creates possible conflict if `FILENAME` matches an existing template.)
Any help would be appreciated!
https://redd.it/zbjpo5
@r_bash
I'm trying to debug my CLI tool ([https://github.com/membersincewayback/gen](https://github.com/membersincewayback/gen)) and address unset variables, however I just realized one of my parameter expansions isn't working how I thought it was supposed to as below:
#!/usr/bin/env bash
FILENAME="${!#}"
EXT="${FILENAME##*.}"
The intention is to set `FILENAME` to the last argument (working) and `EXT` to anything following the final "." (not working as expected). The problem is, if there is no "." it sets `EXT` == `FILENAME` which has undesired effects on the rest of the noscript. (i.e. creates possible conflict if `FILENAME` matches an existing template.)
Any help would be appreciated!
https://redd.it/zbjpo5
@r_bash
GitHub
GitHub - membersincewayback/gen: A command line noscript automation tool written in bash 3.2+
A command line noscript automation tool written in bash 3.2+ - GitHub - membersincewayback/gen: A command line noscript automation tool written in bash 3.2+
making menu: some doubts about the best way I'm doing it. Am I right? Is there a better way to do this?
Hi,
I'm making a noscript with a big menù for config my homeserver (see the code at the end of post)... now I'm questioning myself if there is a better way to write the menu. Questions are:
1. the `INITIAL_MANDATORY_SERVER_CONFIG_MENU` list, could be written in a different place, for example in the constraints part of the noscript, at the beginning? It seems no..
2. `INITIAL_MANDATORY_SERVER_CONFIG_MENU` could be written in a different way, for example `INITIAL_MANDATORY_SERVER_CONFIG_MENU=( "INIZIALIZZA" "INSTALL AND UPGRADE STABLE SOURCES" ...)` ? It seems no...
3. Otherwise, should I organize the menu in a complete different way?
thanks for any advice.
​
​
INITIAL_MANDATORY_SERVER_CONFIG_MENU=(
"INIZIALIZZA"
"INSTALL AND UPGRADE STABLE SOURCES"
"INSTALL NEW STABLE SOFTWARES"
"INSTALL DOCKER + DOCKER-COMPOSE"
"CREATE USERS"
"CONFIG WIREGUARD ADMIN"
"CONFIG WIREGUARD HOME"
"CONFIG WIREGUARD PARENTS"
"CONFIG SERVER RSYNC"
"CONFIG CRON JOBS"
"CONFIG NetworkUpsTools"
"CONFIG COCKPIT"
"RACKNERD VPS MANAGEMENT SCRIPTS"
"CREATE SWAPFILE"
"LAST GLOBAL CONFIGs"
)
PS3='CHOOSE INITIAL_MANDATORY_SERVER_CONFIG_MENU_VOICE: '
select INITIAL_MANDATORY_SERVER_CONFIG_MENU_VOICE in "${INITIAL_MANDATORY_SERVER_CONFIG_MENU[@]}"
do
case $INITIAL_MANDATORY_SERVER_CONFIG_MENU_VOICE in
https://redd.it/zc775q
@r_bash
Hi,
I'm making a noscript with a big menù for config my homeserver (see the code at the end of post)... now I'm questioning myself if there is a better way to write the menu. Questions are:
1. the `INITIAL_MANDATORY_SERVER_CONFIG_MENU` list, could be written in a different place, for example in the constraints part of the noscript, at the beginning? It seems no..
2. `INITIAL_MANDATORY_SERVER_CONFIG_MENU` could be written in a different way, for example `INITIAL_MANDATORY_SERVER_CONFIG_MENU=( "INIZIALIZZA" "INSTALL AND UPGRADE STABLE SOURCES" ...)` ? It seems no...
3. Otherwise, should I organize the menu in a complete different way?
thanks for any advice.
​
​
INITIAL_MANDATORY_SERVER_CONFIG_MENU=(
"INIZIALIZZA"
"INSTALL AND UPGRADE STABLE SOURCES"
"INSTALL NEW STABLE SOFTWARES"
"INSTALL DOCKER + DOCKER-COMPOSE"
"CREATE USERS"
"CONFIG WIREGUARD ADMIN"
"CONFIG WIREGUARD HOME"
"CONFIG WIREGUARD PARENTS"
"CONFIG SERVER RSYNC"
"CONFIG CRON JOBS"
"CONFIG NetworkUpsTools"
"CONFIG COCKPIT"
"RACKNERD VPS MANAGEMENT SCRIPTS"
"CREATE SWAPFILE"
"LAST GLOBAL CONFIGs"
)
PS3='CHOOSE INITIAL_MANDATORY_SERVER_CONFIG_MENU_VOICE: '
select INITIAL_MANDATORY_SERVER_CONFIG_MENU_VOICE in "${INITIAL_MANDATORY_SERVER_CONFIG_MENU[@]}"
do
case $INITIAL_MANDATORY_SERVER_CONFIG_MENU_VOICE in
https://redd.it/zc775q
@r_bash
reddit
making menu: some doubts about the best way I'm doing it. Am I...
Hi, I'm making a noscript with a big menù for config my homeserver (see the code at the end of post)... now I'm questioning myself if there is a...
Command not found
When I try to use `date = ($date)` it says that the "command was not found". This is also the case for other commands like pwd and whoami. Anyone know whats up?
https://redd.it/zcj8rl
@r_bash
When I try to use `date = ($date)` it says that the "command was not found". This is also the case for other commands like pwd and whoami. Anyone know whats up?
https://redd.it/zcj8rl
@r_bash
reddit
Command not found
When I try to use \`date = ($date)\` it says that the "command was not found". This is also the case for other commands like pwd and whoami....
How to create a bashrc url fetch noscript?
I'm complete noob when it comes to shell and i'm learning so please tolerate me xD
i already have a alias set to download with yt-dlp and wget but can somone write me a noscript that i could put in my bashrc so i can just put the url without any alias in the terminal and start downloading like for example if i use https://youtu* it would start using yt-dlp and if i put https://** if would start using wget??
Thank you!
https://redd.it/zcoav5
@r_bash
I'm complete noob when it comes to shell and i'm learning so please tolerate me xD
i already have a alias set to download with yt-dlp and wget but can somone write me a noscript that i could put in my bashrc so i can just put the url without any alias in the terminal and start downloading like for example if i use https://youtu* it would start using yt-dlp and if i put https://** if would start using wget??
Thank you!
https://redd.it/zcoav5
@r_bash
reddit
How to create a bashrc url fetch noscript?
I'm complete noob when it comes to shell and i'm learning so please tolerate me xD i already have a alias set to download with yt-dlp and wget...
Need some help with a ffmpeg bash noscript
This is what I have:
#!/usr/bin/env bash
set -e
mkdir -p $HOME/Videos/WhatsPrep 2>/dev/null || true
for i in "$@"; do output=$(ls "$@" /path/glob | tr '\n' '\0' | xargs -0 -n 1 basename); ffmpeg -hide_banner -y -i "$i" -c:v libx264 -c:a aac -filter_complex scale=w=-2:h=720 -crf 24 -movflags +faststart -pix_fmt yuv420p "$HOME/Videos/WhatsPrep/${output%.*}.mp4"; done
What I'm trying to do is to let ffmpeg convert multiple files which are in different locations. However they create a single file with a filename which contains all output filenames. What am I doing wrong?
https://redd.it/zcri87
@r_bash
This is what I have:
#!/usr/bin/env bash
set -e
mkdir -p $HOME/Videos/WhatsPrep 2>/dev/null || true
for i in "$@"; do output=$(ls "$@" /path/glob | tr '\n' '\0' | xargs -0 -n 1 basename); ffmpeg -hide_banner -y -i "$i" -c:v libx264 -c:a aac -filter_complex scale=w=-2:h=720 -crf 24 -movflags +faststart -pix_fmt yuv420p "$HOME/Videos/WhatsPrep/${output%.*}.mp4"; done
What I'm trying to do is to let ffmpeg convert multiple files which are in different locations. However they create a single file with a filename which contains all output filenames. What am I doing wrong?
https://redd.it/zcri87
@r_bash
reddit
Need some help with a ffmpeg bash noscript
This is what I have: #!/usr/bin/env bash set -e mkdir -p $HOME/Videos/WhatsPrep 2>/dev/null || true for i in "$@"; do...
How can I write something into a file on an non-interactive shell?
I am relatively new to bash. I am trying to write something into a file using bash and Java.
In the interactive mode it works fine.
echo "Hello World" > new_file
But when I am, e.g. trying to execute this with help of the Java runtime nothing happens.
runtime.exec('echo "Hello World" > new_file');
doesn't work, while
runtime.exec('touch new_file');
works just fine.
Why is that and how can I make it work? Thanks in advance!
https://redd.it/zd1fnt
@r_bash
I am relatively new to bash. I am trying to write something into a file using bash and Java.
In the interactive mode it works fine.
echo "Hello World" > new_file
But when I am, e.g. trying to execute this with help of the Java runtime nothing happens.
runtime.exec('echo "Hello World" > new_file');
doesn't work, while
runtime.exec('touch new_file');
works just fine.
Why is that and how can I make it work? Thanks in advance!
https://redd.it/zd1fnt
@r_bash
reddit
How can I write something into a file on an non-interactive shell?
I am relatively new to bash. I am trying to write something into a file using bash and Java. In the interactive mode it works fine. echo...
What is @SOMETHING@ assigned to variable
Trying to read a bash noscript and I'm baffled with this construction. Never seen that before. Can some1 explain that to me?
https://redd.it/zd1rnx
@r_bash
Trying to read a bash noscript and I'm baffled with this construction. Never seen that before. Can some1 explain that to me?
https://redd.it/zd1rnx
@r_bash
reddit
What is @SOMETHING@ assigned to variable
Trying to read a bash noscript and I'm baffled with this construction. Never seen that before. Can some1 explain that to me?
quotes from command output are treated as literal characters?
i'm trying to build a noscript that opens a dialog box with radio buttons, each button being assigned a name. these names can contain spaces, so obviously i try to quote the output from the array which contains the names.
when i run my current attempt, being
for n in ${!list@}; do
printf "$n "
printf "\"${list$n}\" "
done
it works as intended. it outputs the index of the name, followed by the name itself, in quotes.
giving it
so when i wrap this in a nice $() and use that as arguments for kdialog (or a quick testing noscript that loops through all cli arguments) i would expect the shell to treat the quoted parts as single arguments, rather than treating the quotes as literal characters. so when i make a noscript "test.sh" which contains
#!/usr/bin/bash
for item in $@; do
echo $item
done
and run it like this
0
"test1"
1
"test2"
2
"test 3"
as output but instead i get
0
"test1"
1
"test2"
2
"test
3"
which leads me to believe that the shell is treating the quotes as literal. which sounds an awful lot like it's designed that way.
so is this supposed to happen? and is there a way around it?
i've already checked, single quotes don't work either.
https://redd.it/zd7axm
@r_bash
i'm trying to build a noscript that opens a dialog box with radio buttons, each button being assigned a name. these names can contain spaces, so obviously i try to quote the output from the array which contains the names.
when i run my current attempt, being
for n in ${!list@}; do
printf "$n "
printf "\"${list$n}\" "
done
it works as intended. it outputs the index of the name, followed by the name itself, in quotes.
giving it
list=(test1 test2 "test 3") outputs 0 "test1" 1 "test2" 2 "test 3" which is exactly what i need.so when i wrap this in a nice $() and use that as arguments for kdialog (or a quick testing noscript that loops through all cli arguments) i would expect the shell to treat the quoted parts as single arguments, rather than treating the quotes as literal characters. so when i make a noscript "test.sh" which contains
#!/usr/bin/bash
for item in $@; do
echo $item
done
and run it like this
/test.sh $(for n in ${!list[@]}; do printf "$n "; printf "\"${list[$n]}\" "; done) i would expect to see0
"test1"
1
"test2"
2
"test 3"
as output but instead i get
0
"test1"
1
"test2"
2
"test
3"
which leads me to believe that the shell is treating the quotes as literal. which sounds an awful lot like it's designed that way.
so is this supposed to happen? and is there a way around it?
i've already checked, single quotes don't work either.
https://redd.it/zd7axm
@r_bash
reddit
quotes from command output are treated as literal characters?
i'm trying to build a noscript that opens a dialog box with radio buttons, each button being assigned a name. these names can contain spaces, so...
Help with homebrew and bash
Hi everyone, I've changed my shell to the homebrew bash after installing homebrew in zsh. When I use "brew" it tells me that the command is not found. Is there some way to use both the homebrew bash and also be able to access homebrew while inside that bash?
Currently I am using the /opt/homebrew/bin/bash and it will not allow me to use the “brew” command.
Thank you!
https://redd.it/zdfrfp
@r_bash
Hi everyone, I've changed my shell to the homebrew bash after installing homebrew in zsh. When I use "brew" it tells me that the command is not found. Is there some way to use both the homebrew bash and also be able to access homebrew while inside that bash?
Currently I am using the /opt/homebrew/bin/bash and it will not allow me to use the “brew” command.
Thank you!
https://redd.it/zdfrfp
@r_bash
reddit
Help with homebrew and bash
Hi everyone, I've changed my shell to the homebrew bash after installing homebrew in zsh. When I use "brew" it tells me that the command is not...
Bash syntax - why?
Hi folks,
I just came across the bash syntax for a switch statement. It's... surprising.
Are there any resources online that explain how this syntax came to existence, and why it is still in use today?
https://redd.it/zeepuh
@r_bash
Hi folks,
I just came across the bash syntax for a switch statement. It's... surprising.
Are there any resources online that explain how this syntax came to existence, and why it is still in use today?
https://redd.it/zeepuh
@r_bash
Linuxize
Bash Case Statement
This tutorial will cover the basics of the Bash case statement and show you how to use it in your shell noscripts.
Hey y’all i’m super new to bashing and i’m curious on where to start. I know nothing about bash but i was going to ask if y’all have any resources to help me get started with it? thank you!
https://redd.it/zem5a0
@r_bash
https://redd.it/zem5a0
@r_bash
reddit
Hey y’all i’m super new to bashing and i’m curious on where to...
Posted in r/bash by u/Psychological_One479 • 1 point and 1 comment
Replace hostname
Hi All,
I am planning to replace existing hostname by making simple interactive noscript
#!/bin/bash
echo "Set Hostname"
read name1
name='cat /proc/sys/kernel/hostname'
sed -i 's/$name/$name1/g' /etc/hostname
hostname $name1
The issue here is - it changes hostname. I exit and log back in. I see new hostname. But nothing gets changed in /etc/hostname file. reboot and I am back to old hostname.
​
What am I missing here?
https://redd.it/zexcn4
@r_bash
Hi All,
I am planning to replace existing hostname by making simple interactive noscript
#!/bin/bash
echo "Set Hostname"
read name1
name='cat /proc/sys/kernel/hostname'
sed -i 's/$name/$name1/g' /etc/hostname
hostname $name1
The issue here is - it changes hostname. I exit and log back in. I see new hostname. But nothing gets changed in /etc/hostname file. reboot and I am back to old hostname.
​
What am I missing here?
https://redd.it/zexcn4
@r_bash
reddit
Replace hostname
Hi All, I am planning to replace existing hostname by making simple interactive noscript #!/bin/bash echo "Set Hostname" read name1 ...
Finding a 5 digit code for a locked zip file
As the noscript states, I am looking to create a noscript that goes through 0 to 99999 and once it finds the right code it unlocks and unzips the contents. I know the use of a for loop and it will be slow but that's nothing to worry about for my noscript. The locked file is using 7-zip.
https://redd.it/zey4h8
@r_bash
As the noscript states, I am looking to create a noscript that goes through 0 to 99999 and once it finds the right code it unlocks and unzips the contents. I know the use of a for loop and it will be slow but that's nothing to worry about for my noscript. The locked file is using 7-zip.
https://redd.it/zey4h8
@r_bash
reddit
Finding a 5 digit code for a locked zip file
As the noscript states, I am looking to create a noscript that goes through 0 to 99999 and once it finds the right code it unlocks and unzips the...