shell...???
What is the website I'm thinking of!!!??? We use it all the time for bash noscripting, and I can not figure it outt. I'm pretty sure it's shell something, but nothing so far sounds right. Can anyone help me or at least explain what this is doing, I get the general idea, but I'm curious how it helps make noscripts ready for reddit.
echo ; sed 's/^/ /' noscript.sh
https://redd.it/10mepie
@r_bash
What is the website I'm thinking of!!!??? We use it all the time for bash noscripting, and I can not figure it outt. I'm pretty sure it's shell something, but nothing so far sounds right. Can anyone help me or at least explain what this is doing, I get the general idea, but I'm curious how it helps make noscripts ready for reddit.
echo ; sed 's/^/ /' noscript.sh
https://redd.it/10mepie
@r_bash
Reddit
r/bash - shell...???
Posted in the bash community.
Help with a scheduled (cron) bash noscript
Hi everyone, I’m new to this sub so I apologize in advance for any mistakes.
I created a noscript that checks if a python application is running and if not starts it. This is what it looks like:
#!/bin/bash
if pgrep -x "python3.10" > /dev/null
then
echo "Application is running."
else
source dev/bin/activate
cd dev
nohup python3.10 main.py > output.log 2>&1 &
echo "Application restarted."
fi`
This code works perfectly fine when I run it from the terminal, however, when I try to run it using cron I get the correct output but main.py doesn’t actually start.
I’m not sure what I’m doing wrong. Any help would be appreciated!
https://redd.it/10mjh9x
@r_bash
Hi everyone, I’m new to this sub so I apologize in advance for any mistakes.
I created a noscript that checks if a python application is running and if not starts it. This is what it looks like:
#!/bin/bash
if pgrep -x "python3.10" > /dev/null
then
echo "Application is running."
else
source dev/bin/activate
cd dev
nohup python3.10 main.py > output.log 2>&1 &
echo "Application restarted."
fi`
This code works perfectly fine when I run it from the terminal, however, when I try to run it using cron I get the correct output but main.py doesn’t actually start.
I’m not sure what I’m doing wrong. Any help would be appreciated!
https://redd.it/10mjh9x
@r_bash
Reddit
r/bash - Help with a scheduled (cron) bash noscript
Posted in the bash community.
Interesting bash malware
https://www.trendmicro.com/en_gb/research/21/f/bash-ransomware-darkradiation-targets-red-hat--and-debian-based-linux-distributions.html
https://redd.it/10mmz8r
@r_bash
https://www.trendmicro.com/en_gb/research/21/f/bash-ransomware-darkradiation-targets-red-hat--and-debian-based-linux-distributions.html
https://redd.it/10mmz8r
@r_bash
Trend Micro
Bash Ransomware DarkRadiation Targets Red Hat- and Debian-based Linux Distributions
We investigate how certain hacking tools are used to move laterally on victims’ networks to deploy ransomware. These tools contain reconnaissance/spreader noscripts, exploits for Red Hat and CentOS, binary injectors, and more. In this blog, we focus on analyzing…
Bashkit V1
The first public release of BashkitV1 is now available with the URL
https://bashkit.wuage.io
and from the main branch of the Bashkit git repository
(https://github.com/Wuageorg/bashkit).
Bashkit is the Wuage’s shell noscripting framework. It is a collection of pure bash functions along with a lightweight noscripting model that, we believe, remediate some of the Bash quirks.
Out of the box, It supports advanced yet classical logging (including NDJSON), fail fast noscripting pattern (less to none `set -e` side effects), coloured outputs and more. It can easily be extended by adding modules to accommodate various use cases.
For more information on the features of Bashkit that are new to this type of shell noscripts, see the file `doc/manual.pdf’. There is also Unix-style man pages for every released function. The man pages are the definitive denoscriptions of the framework’s features.
The framework is released under APACHE LICENSE, VERSION 2.0.
The release tar file includes the formatted documentation (pdf).
Please use https://github.com/Wuageorg/bashkit/issues to report bugs with this version. It complements at least bash 5.x and can not be used without.
Happy noscripting!
The Wuage Team
Jan. 2023
https://redd.it/10moz5g
@r_bash
The first public release of BashkitV1 is now available with the URL
https://bashkit.wuage.io
and from the main branch of the Bashkit git repository
(https://github.com/Wuageorg/bashkit).
Bashkit is the Wuage’s shell noscripting framework. It is a collection of pure bash functions along with a lightweight noscripting model that, we believe, remediate some of the Bash quirks.
Out of the box, It supports advanced yet classical logging (including NDJSON), fail fast noscripting pattern (less to none `set -e` side effects), coloured outputs and more. It can easily be extended by adding modules to accommodate various use cases.
For more information on the features of Bashkit that are new to this type of shell noscripts, see the file `doc/manual.pdf’. There is also Unix-style man pages for every released function. The man pages are the definitive denoscriptions of the framework’s features.
The framework is released under APACHE LICENSE, VERSION 2.0.
The release tar file includes the formatted documentation (pdf).
Please use https://github.com/Wuageorg/bashkit/issues to report bugs with this version. It complements at least bash 5.x and can not be used without.
Happy noscripting!
The Wuage Team
Jan. 2023
https://redd.it/10moz5g
@r_bash
Echo commands IN variable
How would I place echo commands inside a variable? I am attempting to send an email with postfix under certain circumstances. For example:
OUTPUT=$(MP4Box -info $INPUTFILE 2>&1)
HTML="<pre style=\"white-space: pre-wrap; word-break: keep-all; background-color: whitesmoke;\"><code>${OUTPUT}</code></pre>"
if [[ $(MP4Box -info $INPUTFILE 2>&1) =~ "Incomplete" ]];
then
(
echo "From: from@email.com";
echo "To: send@email.com";
echo "Subject: Transfer Interrupted";
echo "Content-Type: text/html";
echo "MIME-Version: 1.0";
echo "";
echo -e "The mp4 transfer was interrupted and did not complete." \
"The output is as follows:\n\n" \
"${HTML}"
) | sendmail -t
elif [ $(MP4Box -info $INPUT_FILE 2>&1) =~ "Movie Info" ];
then
(
echo "From: from@email.com";
echo "To: send@email.com";
echo "Subject: Transfer complete.";
echo "Content-Type: text/html";
echo "MIME-Version: 1.0";
echo "";
echo -e "The mp4 transfer is complete." \
"The output is as follows:\n\n" \
"${HTML}"
) | sendmail -t
else
(
echo "From: from@email.com";
echo "To: send@email.com";
echo "Subject: Check on Transfer.";
echo "Content-Type: text/html";
echo "MIME-Version: 1.0";
echo "";
echo -e "Something could be wrong. Manually check the mp4." \
"The output is as follows:\n\n" \
"${HTML}"
) | sendmail -t
fi
I would like to simplify this with variables. When I try, I get the postfix error
OUTPUT=$(MP4Box -info $INPUTFILE 2>&1)
HTML="<pre style=\"white-space: pre-wrap; word-break: keep-all; background-color: whitesmoke;\"><code>${OUTPUT}</code></pre>"
EMAILHEADER=$(echo "From: from@email.com";
echo "To: send@email.com";
echo "Subject: ${SUBJECT}";
echo "Content-Type: text/html";
echo "MIME-Version: 1.0";
echo "";)
if [[ $(MP4Box -info $INPUTFILE 2>&1) =~ "Incomplete" ]];
then
(
$EMAILHEADER
echo -e "The mp4 transfer was interrupted and did not complete." \
"The output is as follows:\n\n" \
"${HTML}"
) | sendmail -t
elif [ $(MP4Box -info $INPUT_FILE 2>&1) =~ "Movie Info" ];
then
(
$EMAILHEADER
echo -e "The mp4 transfer is complete." \
"The output is as follows:\n\n" \
"${HTML}"
) | sendmail -t
else
(
$EMAILHEADER
echo -e "Something could be wrong. Manually check the mp4." \
"The output is as follows:\n\n" \
"${HTML}"
) | sendmail -t
fi
I know I still have to define
I have one additional question... how can I break up the
HTML="<pre style=\"white-space: pre-wrap; word-break: keep-all; background-color: whitesmoke;\"><code>${OUTPUT}</code></pre>"
I want something like:
HTML="<pre style=\"white-space: pre-wrap; word-break: keep-all;" \
"background-color: whitesmoke;\"><code>${OUTPUT}</code></pre>"
But this fails for me (doesn't print out in the email).
https://redd.it/10mwah8
@r_bash
How would I place echo commands inside a variable? I am attempting to send an email with postfix under certain circumstances. For example:
OUTPUT=$(MP4Box -info $INPUTFILE 2>&1)
HTML="<pre style=\"white-space: pre-wrap; word-break: keep-all; background-color: whitesmoke;\"><code>${OUTPUT}</code></pre>"
if [[ $(MP4Box -info $INPUTFILE 2>&1) =~ "Incomplete" ]];
then
(
echo "From: from@email.com";
echo "To: send@email.com";
echo "Subject: Transfer Interrupted";
echo "Content-Type: text/html";
echo "MIME-Version: 1.0";
echo "";
echo -e "The mp4 transfer was interrupted and did not complete." \
"The output is as follows:\n\n" \
"${HTML}"
) | sendmail -t
elif [ $(MP4Box -info $INPUT_FILE 2>&1) =~ "Movie Info" ];
then
(
echo "From: from@email.com";
echo "To: send@email.com";
echo "Subject: Transfer complete.";
echo "Content-Type: text/html";
echo "MIME-Version: 1.0";
echo "";
echo -e "The mp4 transfer is complete." \
"The output is as follows:\n\n" \
"${HTML}"
) | sendmail -t
else
(
echo "From: from@email.com";
echo "To: send@email.com";
echo "Subject: Check on Transfer.";
echo "Content-Type: text/html";
echo "MIME-Version: 1.0";
echo "";
echo -e "Something could be wrong. Manually check the mp4." \
"The output is as follows:\n\n" \
"${HTML}"
) | sendmail -t
fi
I would like to simplify this with variables. When I try, I get the postfix error
No recipient addresses found in message header. For example:OUTPUT=$(MP4Box -info $INPUTFILE 2>&1)
HTML="<pre style=\"white-space: pre-wrap; word-break: keep-all; background-color: whitesmoke;\"><code>${OUTPUT}</code></pre>"
EMAILHEADER=$(echo "From: from@email.com";
echo "To: send@email.com";
echo "Subject: ${SUBJECT}";
echo "Content-Type: text/html";
echo "MIME-Version: 1.0";
echo "";)
if [[ $(MP4Box -info $INPUTFILE 2>&1) =~ "Incomplete" ]];
then
(
$EMAILHEADER
echo -e "The mp4 transfer was interrupted and did not complete." \
"The output is as follows:\n\n" \
"${HTML}"
) | sendmail -t
elif [ $(MP4Box -info $INPUT_FILE 2>&1) =~ "Movie Info" ];
then
(
$EMAILHEADER
echo -e "The mp4 transfer is complete." \
"The output is as follows:\n\n" \
"${HTML}"
) | sendmail -t
else
(
$EMAILHEADER
echo -e "Something could be wrong. Manually check the mp4." \
"The output is as follows:\n\n" \
"${HTML}"
) | sendmail -t
fi
I know I still have to define
$SUBJECT and will get to that, but I at least want to get the basics of this working first.I have one additional question... how can I break up the
HTML= line (within the noscript)? It's long and I want to make it two lines to make the noscript more readable. So instead of:HTML="<pre style=\"white-space: pre-wrap; word-break: keep-all; background-color: whitesmoke;\"><code>${OUTPUT}</code></pre>"
I want something like:
HTML="<pre style=\"white-space: pre-wrap; word-break: keep-all;" \
"background-color: whitesmoke;\"><code>${OUTPUT}</code></pre>"
But this fails for me (doesn't print out in the email).
https://redd.it/10mwah8
@r_bash
Reddit
r/bash on Reddit
Echo commands IN variable - No votes and 1 comment
cannot run a noscript in /app directory
Trying to run a bash noscript. when i save it in my home, it can run just fine but when I move the noscript to a /app location, the noscript does not run. All permissions are ok but when i run the noscript, it does not run and also does not return an error. I also noticed that the color code I have in the noscript in my home is not appearing in when i have a noscript in the /app location. please help if you have any idea what the issue is here.
https://redd.it/10mvsvh
@r_bash
Trying to run a bash noscript. when i save it in my home, it can run just fine but when I move the noscript to a /app location, the noscript does not run. All permissions are ok but when i run the noscript, it does not run and also does not return an error. I also noticed that the color code I have in the noscript in my home is not appearing in when i have a noscript in the /app location. please help if you have any idea what the issue is here.
https://redd.it/10mvsvh
@r_bash
Reddit
r/bash - cannot run a noscript in /app directory
Posted in the bash community.
text editor in bash!
https://github.com/Agb43/text-editor.git
​
I decided to write a terminal based text editor in bash for fun. Considering that i've never taken a coding class in my life, i'm pretty proud of it, even if inserting whitespace via blank echos is incredibly bad im sure.
https://redd.it/10n6u6m
@r_bash
https://github.com/Agb43/text-editor.git
​
I decided to write a terminal based text editor in bash for fun. Considering that i've never taken a coding class in my life, i'm pretty proud of it, even if inserting whitespace via blank echos is incredibly bad im sure.
https://redd.it/10n6u6m
@r_bash
GitHub
GitHub - Agb43/text-editor
Contribute to Agb43/text-editor development by creating an account on GitHub.
Changing placeholder denoscription via sed
Hi! As an input for sed program I have smth like this:
-
-
How do I replace all such placeholders to this
https://redd.it/10nblyy
@r_bash
Hi! As an input for sed program I have smth like this:
{bool some flag denoscription} (it's a part of an input string to be more precise) where:-
bool is a placeholder type-
some flag denoscription is it's denoscriptionHow do I replace all such placeholders to this
{{some_flag_denoscription}}? I don't know how to replace spaces between 3 denoscription words with underscores. What sed technique should I use? I wanna transform some flag denoscription in a such way not to broke the whole placeholder. Another difficulty is that this placeholder can appear in any place in a command invocation example like some_executable --dark {bool whether to enable dark more} --colorize {bool whether to colorize files}. I need to know how to do this to fix my noscript.https://redd.it/10nblyy
@r_bash
GitHub
prototypes/md-to-btldr.sh at main · emilyseville7cfg-better-tldr/prototypes
Tool prototypes written in different languages. Contribute to emilyseville7cfg-better-tldr/prototypes development by creating an account on GitHub.
Beginner having trouble using variables as literal strings
Hello,
I'm new to Bash, and I've been hammering my way through issues with the help of ChatGPT, but it's running me in circles on this one.
I'm using Curl to make a request to Pushover's API. Many of the options that I call Curl with are exactly the same, so I thought that I'd put them in a variable to make things easier. I know that In an actual request, I would have to include more options, but I wanted to trim this example down.
po_token="ExampleToken"
po_user="ExampleUserKey"
curl_ops='-s -o "/dev/null" --connect-timeout "5" --retry "6" --retry-delay "600" -F "token=$po_token" -F "user=$po_user" "https://api.pushover.net/1/messages.json"'
curl $curl_ops
It seems that everything in my "curl_ops" variable is being passed as a single argument instead of a literal string, and I'm certain it has to do with my usage of quotes, but I have no idea how to fix it. The only noscripting language that I'm familiar with is AutoIt, and Bash seems to handle this kind of thing very differently. I was hoping someone here may have some suggestions.
Thanks
https://redd.it/10nbdv5
@r_bash
Hello,
I'm new to Bash, and I've been hammering my way through issues with the help of ChatGPT, but it's running me in circles on this one.
I'm using Curl to make a request to Pushover's API. Many of the options that I call Curl with are exactly the same, so I thought that I'd put them in a variable to make things easier. I know that In an actual request, I would have to include more options, but I wanted to trim this example down.
po_token="ExampleToken"
po_user="ExampleUserKey"
curl_ops='-s -o "/dev/null" --connect-timeout "5" --retry "6" --retry-delay "600" -F "token=$po_token" -F "user=$po_user" "https://api.pushover.net/1/messages.json"'
curl $curl_ops
It seems that everything in my "curl_ops" variable is being passed as a single argument instead of a literal string, and I'm certain it has to do with my usage of quotes, but I have no idea how to fix it. The only noscripting language that I'm familiar with is AutoIt, and Bash seems to handle this kind of thing very differently. I was hoping someone here may have some suggestions.
Thanks
https://redd.it/10nbdv5
@r_bash
how to supress this
hi
im using psexec example PSEXEC \\\\workstation64 x:\\runme.bat
noscripts runs fine how ever i want to supress the displaying of the exit code here is the output
at exited on srv1 with error code 0.
https://redd.it/10nl7yc
@r_bash
hi
im using psexec example PSEXEC \\\\workstation64 x:\\runme.bat
noscripts runs fine how ever i want to supress the displaying of the exit code here is the output
at exited on srv1 with error code 0.
https://redd.it/10nl7yc
@r_bash
Reddit
r/bash on Reddit: how to supress this
Posted by u/b33zm1ne - No votes and 1 comment
Is there a difference between " tr a-z n-za-m " and " tr 'a-z' 'n-zam' " ?
Both provide the same output, but I'm seeing online people are recommending using " tr '[a-z\]' '[n-za-m\]' "
Why is that?
https://redd.it/10ny8a4
@r_bash
Both provide the same output, but I'm seeing online people are recommending using " tr '[a-z\]' '[n-za-m\]' "
Why is that?
https://redd.it/10ny8a4
@r_bash
Reddit
Is there a difference between " tr a-z n-za-m " and " tr '[a-z]' '[n-zam]' " ?
Posted in the bash community.
Linux bash practice site
HI, I am preparing for OSCP and hence I am learning bash.
Can someone please suggest me a best place to practice bash(For linux).
Any online link would be helpfull
https://redd.it/10o0z6g
@r_bash
HI, I am preparing for OSCP and hence I am learning bash.
Can someone please suggest me a best place to practice bash(For linux).
Any online link would be helpfull
https://redd.it/10o0z6g
@r_bash
Reddit
r/bash on Reddit
Linux bash practice site - No votes and no comments
What is wrong with this noscript?
Trying to grep an array of strings from a file on a remote server but the noscript does seem to do it, I might be missing quotes or the use of array is wrong here?
PARAMS=(“abc” “xyz” “ijk”)
REMOTEFILE=“pathtoFile”
NODES=(“srv1” “srv2”)
for srv in “${NODES@}”
do
ssh $srv << EOF
grep -f “${PARAMS@}” $REMOTEFILE >/path/remotefile.txt
EOF
done
https://redd.it/10nxxc0
@r_bash
Trying to grep an array of strings from a file on a remote server but the noscript does seem to do it, I might be missing quotes or the use of array is wrong here?
PARAMS=(“abc” “xyz” “ijk”)
REMOTEFILE=“pathtoFile”
NODES=(“srv1” “srv2”)
for srv in “${NODES@}”
do
ssh $srv << EOF
grep -f “${PARAMS@}” $REMOTEFILE >/path/remotefile.txt
EOF
done
https://redd.it/10nxxc0
@r_bash
Reddit
r/bash on Reddit
What is wrong with this noscript?
Cannot backup a directory with tar. When i am trying to run the noscript it says "Cannot stat: No such file or directory". What is the problem? How to resolve it? Or maybe there is some other way to backup a directory. Please help
https://redd.it/10o3h0k
@r_bash
https://redd.it/10o3h0k
@r_bash
Reddit
r/bash on Reddit
Cannot backup a directory with tar. When i am tryi... - No votes and 3 comments
How can I modify this bash command that will also output the content of the given file.
https://redd.it/10o2qi5
@r_bash
https://redd.it/10o2qi5
@r_bash