noobish type having trouble creating an executable file from a bash noscript. most answers are people trying to make a file executable after its written. id like to know how to make one while its written.
I'm 100% I'm just being dumb and missing the obvious, as I often do, so any help would be greatly and humbly received. I know how to create a file with permissions, I understand perfectly chmod +x and all the numbers you can use e.g. 700, all permissions to me and no users or groups. I know that 111 101 100 would be rwx/r-x/r-- or 754 etc. but what I'm having trouble with is writing a bash noscript that creates another executable bash noscript. This would be super handy for making test blank noscripts without going through the rigmarole of changing the permissions every time, be it through terminal or properties. I'm sure there's a way, but everything I've tried has failed. ive tried-
chmod +x; touch /filepath/noscript.sh
touch /filepath/noscript.sh; chmod +x
touch /filepath/noscript.sh && chmod +x
touch /filepath/noscript.sh chmod +x
touch /filepath/noscript.sh | chmod +x
i can't think of another way to try.
​
​
(these are just the basic ideas I've tried with numbers too in all the other variations)
I'd also love someone to point out why these aren't working i know why the bottom two dont work
https://redd.it/zlfqr4
@r_bash
I'm 100% I'm just being dumb and missing the obvious, as I often do, so any help would be greatly and humbly received. I know how to create a file with permissions, I understand perfectly chmod +x and all the numbers you can use e.g. 700, all permissions to me and no users or groups. I know that 111 101 100 would be rwx/r-x/r-- or 754 etc. but what I'm having trouble with is writing a bash noscript that creates another executable bash noscript. This would be super handy for making test blank noscripts without going through the rigmarole of changing the permissions every time, be it through terminal or properties. I'm sure there's a way, but everything I've tried has failed. ive tried-
chmod +x; touch /filepath/noscript.sh
touch /filepath/noscript.sh; chmod +x
touch /filepath/noscript.sh && chmod +x
touch /filepath/noscript.sh chmod +x
touch /filepath/noscript.sh | chmod +x
i can't think of another way to try.
​
​
(these are just the basic ideas I've tried with numbers too in all the other variations)
I'd also love someone to point out why these aren't working i know why the bottom two dont work
https://redd.it/zlfqr4
@r_bash
reddit
noobish type having trouble creating an executable file from a...
I'm 100% I'm just being dumb and missing the obvious, as I often do, so any help would be greatly and humbly received. I know how to create a file...
Working but not really
Hello! I'm trying to make the code in the link wok: https://www.geeksforgeeks.org/shell-noscript-to-scrap-the-definition-of-a-word-from-wikipedia/
​
However, even changing the syntax error of "fi", I still get no output. Anyone have an idea how to fix this
https://redd.it/zleno7
@r_bash
Hello! I'm trying to make the code in the link wok: https://www.geeksforgeeks.org/shell-noscript-to-scrap-the-definition-of-a-word-from-wikipedia/
​
However, even changing the syntax error of "fi", I still get no output. Anyone have an idea how to fix this
https://redd.it/zleno7
@r_bash
GeeksforGeeks
Shell Script to Scrap the Definition of a Word From Wikipedia - GeeksforGeeks
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
My kubectl bash noscript not working
I want to switch user to ansible when i exec into a k8s pod but my noscript is not working:
Kubectl exec -it -n $pod /bin/bash -c “su ansible && echo whoami”
https://redd.it/zlejyp
@r_bash
I want to switch user to ansible when i exec into a k8s pod but my noscript is not working:
Kubectl exec -it -n $pod /bin/bash -c “su ansible && echo whoami”
https://redd.it/zlejyp
@r_bash
reddit
My kubectl bash noscript not working
I want to switch user to ansible when i exec into a k8s pod but my noscript is not working: Kubectl exec -it -n $pod /bin/bash -c “su ansible &&...
Bash adding extra single quotes when running noscript
I'm making a noscript to convert mp4 to mkv while embedding subnoscripts but it doesn't work. If I am to put echo before mkverge on the last line and copy/paste the output into the terminal, it runs fine.
Here is a copy of the noscript:
#!/bin/bash
subfile=$(sed 's/mp4/eng.srt/' <<< "$1")
sdhsubfile=$(sed 's/mp4/eng.sdh.srt/' <<< "$1")
forcedsubfile=$(sed 's/mp4/eng.forced.srt/' <<< "$1")
outfile=$(sed 's/mp4/mkv/' <<< "$1")
if test -f "$subfile"; then
mainsrt='--track-name "0:English" --language "0:eng" '"$subfile"
fi
if test -f "$forcedsubfile"; then
forcedsrt='--track-name "0:English (Forced)" --language "0:eng" --forced-track "0:yes" --default-track "0:yes" '"$forcedsubfile"
fi
if test -f "$sdhsubfile"; then
sdhsrt='--track-name "0:English" --language "0:eng" "$subfile" --track-name "0:English (SDH)" --language "0:eng" '"$sdhsubfile"
fi
mkvmerge -o "$2/$outfile" "$1" "$mainsrt" "$forcedsrt" "$sdhsrt"
I added -x to the command so I could see the output and saw the following:
$ for i in *.mp4; do bash -x /noscripts/mp4_srt_to_mkv.sh "$i" "/home/username"; done
++ sed s/mp4/eng.srt/
+ subfile='Movie Name (2000) [Bluray-1080p-x265].eng.srt'
++ sed s/mp4/eng.sdh.srt/
+ sdhsubfile='Movie Name (2000) [Bluray-1080p-x265].eng.sdh.srt'
++ sed s/mp4/eng.forced.srt/
+ forcedsubfile='Movie Name (2000) [Bluray-1080p-x265].eng.forced.srt'
++ sed s/mp4/mkv/
+ outfile='Movie Name (2000) [Bluray-1080p-x265].mkv'
+ test -f 'Movie Name (2000) [Bluray-1080p-x265].eng.srt'
+ mainsrt='--track-name "0:English" --language "0:eng" Movie Name (2000) [Bluray-1080p-x265].eng.srt'
+ test -f 'Movie Name (2000) [Bluray-1080p-x265].eng.forced.srt'
+ forcedsrt='--track-name "0:English (Forced)" --language "0:eng" --forced-track "0:yes" --default-track "0:yes" Movie Name (2000) [Bluray-1080p-x265].eng.forced.srt'
+ test -f 'Movie Name (2000) [Bluray-1080p-x265].eng.sdh.srt'
+ mkvmerge -o '/home/username/Movie Name (2000) [Bluray-1080p-x265].mkv' 'Movie Name (2000) [Bluray-1080p-x265].mp4' '--track-name "0:English" --language "0:eng" Movie Name (2000) [Bluray-1080p-x265].eng.srt' '--track-name "0:English (Forced)" --language "0:eng" --forced-track "0:yes" --default-track "0:yes" Movie Name (2000) [Bluray-1080p-x265].eng.forced.srt' ''
mkvmerge v65.0.0 ('Too Much') 64-bit
Error: The file '--track-name "0:English" --language "0:eng" Movie Name (2000) [Bluray-1080p-x265].eng.srt' could not be opened for reading: open file error.
From looking at the output its adding a ' on the variables containing the subnoscript stuff which makes the command invalid. One example is before --track-name
The purpose of the "if test" lines is to test if the file exists - as not all files will have all subnoscript types and I wanted to make one noscript that works for all by having the noscript check if the file exists.
System info:
Ubuntu 22.04 Server
GNU bash, version 5.1.16(1)-release (x86\_64-pc-linux-gnu)
https://redd.it/zlkdo0
@r_bash
I'm making a noscript to convert mp4 to mkv while embedding subnoscripts but it doesn't work. If I am to put echo before mkverge on the last line and copy/paste the output into the terminal, it runs fine.
Here is a copy of the noscript:
#!/bin/bash
subfile=$(sed 's/mp4/eng.srt/' <<< "$1")
sdhsubfile=$(sed 's/mp4/eng.sdh.srt/' <<< "$1")
forcedsubfile=$(sed 's/mp4/eng.forced.srt/' <<< "$1")
outfile=$(sed 's/mp4/mkv/' <<< "$1")
if test -f "$subfile"; then
mainsrt='--track-name "0:English" --language "0:eng" '"$subfile"
fi
if test -f "$forcedsubfile"; then
forcedsrt='--track-name "0:English (Forced)" --language "0:eng" --forced-track "0:yes" --default-track "0:yes" '"$forcedsubfile"
fi
if test -f "$sdhsubfile"; then
sdhsrt='--track-name "0:English" --language "0:eng" "$subfile" --track-name "0:English (SDH)" --language "0:eng" '"$sdhsubfile"
fi
mkvmerge -o "$2/$outfile" "$1" "$mainsrt" "$forcedsrt" "$sdhsrt"
I added -x to the command so I could see the output and saw the following:
$ for i in *.mp4; do bash -x /noscripts/mp4_srt_to_mkv.sh "$i" "/home/username"; done
++ sed s/mp4/eng.srt/
+ subfile='Movie Name (2000) [Bluray-1080p-x265].eng.srt'
++ sed s/mp4/eng.sdh.srt/
+ sdhsubfile='Movie Name (2000) [Bluray-1080p-x265].eng.sdh.srt'
++ sed s/mp4/eng.forced.srt/
+ forcedsubfile='Movie Name (2000) [Bluray-1080p-x265].eng.forced.srt'
++ sed s/mp4/mkv/
+ outfile='Movie Name (2000) [Bluray-1080p-x265].mkv'
+ test -f 'Movie Name (2000) [Bluray-1080p-x265].eng.srt'
+ mainsrt='--track-name "0:English" --language "0:eng" Movie Name (2000) [Bluray-1080p-x265].eng.srt'
+ test -f 'Movie Name (2000) [Bluray-1080p-x265].eng.forced.srt'
+ forcedsrt='--track-name "0:English (Forced)" --language "0:eng" --forced-track "0:yes" --default-track "0:yes" Movie Name (2000) [Bluray-1080p-x265].eng.forced.srt'
+ test -f 'Movie Name (2000) [Bluray-1080p-x265].eng.sdh.srt'
+ mkvmerge -o '/home/username/Movie Name (2000) [Bluray-1080p-x265].mkv' 'Movie Name (2000) [Bluray-1080p-x265].mp4' '--track-name "0:English" --language "0:eng" Movie Name (2000) [Bluray-1080p-x265].eng.srt' '--track-name "0:English (Forced)" --language "0:eng" --forced-track "0:yes" --default-track "0:yes" Movie Name (2000) [Bluray-1080p-x265].eng.forced.srt' ''
mkvmerge v65.0.0 ('Too Much') 64-bit
Error: The file '--track-name "0:English" --language "0:eng" Movie Name (2000) [Bluray-1080p-x265].eng.srt' could not be opened for reading: open file error.
From looking at the output its adding a ' on the variables containing the subnoscript stuff which makes the command invalid. One example is before --track-name
The purpose of the "if test" lines is to test if the file exists - as not all files will have all subnoscript types and I wanted to make one noscript that works for all by having the noscript check if the file exists.
System info:
Ubuntu 22.04 Server
GNU bash, version 5.1.16(1)-release (x86\_64-pc-linux-gnu)
https://redd.it/zlkdo0
@r_bash
reddit
Bash adding extra single quotes when running noscript
I'm making a noscript to convert mp4 to mkv while embedding subnoscripts but it doesn't work. If I am to put echo before mkverge on the last line and...
BASH shell programming practice problems?
Does anyone know any recourses with some? Ideally just using common commands.
https://redd.it/zlldpo
@r_bash
Does anyone know any recourses with some? Ideally just using common commands.
https://redd.it/zlldpo
@r_bash
reddit
BASH shell programming practice problems?
Does anyone know any recourses with some? Ideally just using common commands.
Help me to convert this code to bash noscript
import sys
​
def main():
print(sys.argv)
print(len(sys.argv))
if len(sys.argv) != 2:
print("Usage: python3", sys.argv[0\], "<string>")
sys.exit(1)
else:
string = sys.argv[1\]
for i in string:
if i.isalpha():
print(i, ":", ord(i) - 96)
else:
print(i, ":", "-")
​
if __name__ == "__main__":
main()
https://redd.it/zll5b9
@r_bash
import sys
​
def main():
print(sys.argv)
print(len(sys.argv))
if len(sys.argv) != 2:
print("Usage: python3", sys.argv[0\], "<string>")
sys.exit(1)
else:
string = sys.argv[1\]
for i in string:
if i.isalpha():
print(i, ":", ord(i) - 96)
else:
print(i, ":", "-")
​
if __name__ == "__main__":
main()
https://redd.it/zll5b9
@r_bash
reddit
Help me to convert this code to bash noscript
import sys def main(): print(sys.argv) print(len(sys.argv)) if len(sys.argv) != 2: print("Usage: python3", sys.argv\[0\],...
question from a newbie. what's the best way to translate reply inputs?
Sorry about formatting, on mobile and its nearly 3 a.m. Right now I'm doing a project making a calculator in bash and I have everything done but one task. I need to translate the input from the operation select menu so it's always lower case. I feel so stupid but I can't figure it out and it's been hours.
This is my first interaction with bash noscripting and I gotten If then down but I'm struggling with loops.
Thank you, if you need my noscript I'll post in a few hours once I get some sleep.
https://redd.it/zll2qu
@r_bash
Sorry about formatting, on mobile and its nearly 3 a.m. Right now I'm doing a project making a calculator in bash and I have everything done but one task. I need to translate the input from the operation select menu so it's always lower case. I feel so stupid but I can't figure it out and it's been hours.
This is my first interaction with bash noscripting and I gotten If then down but I'm struggling with loops.
Thank you, if you need my noscript I'll post in a few hours once I get some sleep.
https://redd.it/zll2qu
@r_bash
reddit
question from a newbie. what's the best way to translate reply inputs?
Sorry about formatting, on mobile and its nearly 3 a.m. Right now I'm doing a project making a calculator in bash and I have everything done but...
How can I make an input function?
I was wondering if it's possible to make a simple function like this, where you can input a string while calling the function
stringLenghtCalculator($inputString){
"$(($(echo $inputString | wc -m)-1))"
}
https://redd.it/zlod9f
@r_bash
I was wondering if it's possible to make a simple function like this, where you can input a string while calling the function
stringLenghtCalculator(hello) and the function calculates the length of the input stringLenghtCalculator($inputString){
"$(($(echo $inputString | wc -m)-1))"
}
https://redd.it/zlod9f
@r_bash
reddit
How can I make an input function?
I was wondering if it's possible to make a simple function like this, where you can input a string while calling the function...
getent passwd {$min..$max} not working, {1000..60000} does
Hi! I'm trying to use getent passwd {$min..$max} in a noscript.
If I echo $min or echo $max before the getent command, it's 1000 and 60000 respectively.
getent passwd {1000..60000} gives me all info I need. Why doesn't variables work?
https://redd.it/zlo2wp
@r_bash
Hi! I'm trying to use getent passwd {$min..$max} in a noscript.
If I echo $min or echo $max before the getent command, it's 1000 and 60000 respectively.
getent passwd {1000..60000} gives me all info I need. Why doesn't variables work?
https://redd.it/zlo2wp
@r_bash
reddit
getent passwd {$min..$max} not working, {1000..60000} does
Hi! I'm trying to use getent passwd {$min..$max} in a noscript. If I echo $min or echo $max before the getent command, it's 1000 and 60000...
cp -rv command without verbosing only the dir name?
Is it possible to print only the dir names (and probably the subdirs) only when using cp with -v?
If the answer is awk, I'd kindly ask the exact solution.
https://redd.it/zlq7vp
@r_bash
Is it possible to print only the dir names (and probably the subdirs) only when using cp with -v?
If the answer is awk, I'd kindly ask the exact solution.
https://redd.it/zlq7vp
@r_bash
reddit
cp -rv command without verbosing only the dir name?
Is it possible to print only the dir names (and probably the subdirs) only when using cp with -v? If the answer is awk, I'd kindly ask the...
Need help with flag names
I have homework where I have to make a noscript that counts words, characters, lines, paragraphs and so on withot using things like wc. I have this done. The thing is, my teacher insists that when running the noscript in terminal, it has to be called like this:
./noscript.sh -file test.txt -number 10
I have all this done and it works, except I have no idea how to make it so that the flag names can be strings and not single characters, without using double dashes --.
Right now I have it like this:
./noscript.sh -f test.txt -n 10
And it all works, but how can I change my getopts (or is there a different way?), so that the flag names can be long?
Also, here is a snippet of my getopts part:
while getopts ":f:n:" opt; do
case $opt in
f) file=$OPTARG
​
Ive also tried doing it like ":file:number:" but it doesnt seem to work
https://redd.it/zltbom
@r_bash
I have homework where I have to make a noscript that counts words, characters, lines, paragraphs and so on withot using things like wc. I have this done. The thing is, my teacher insists that when running the noscript in terminal, it has to be called like this:
./noscript.sh -file test.txt -number 10
I have all this done and it works, except I have no idea how to make it so that the flag names can be strings and not single characters, without using double dashes --.
Right now I have it like this:
./noscript.sh -f test.txt -n 10
And it all works, but how can I change my getopts (or is there a different way?), so that the flag names can be long?
Also, here is a snippet of my getopts part:
while getopts ":f:n:" opt; do
case $opt in
f) file=$OPTARG
​
Ive also tried doing it like ":file:number:" but it doesnt seem to work
https://redd.it/zltbom
@r_bash
reddit
Need help with flag names
I have homework where I have to make a noscript that counts words, characters, lines, paragraphs and so on withot using things like wc. I have this...
Unexpected `Warning: unknown mime-type for ...` from awk
Why I obtain this unexpected error? I don't understand what `awk` wants to be done? Here is my code:
#!/usr/bin/env bash
# Just leading spaces are remvoed and placeholders with square brackets.
# Entries are separated via empty blank lines.
# Anything else is being unthouched.
get_values_and_options() {
declare config_path="$1"
awk 'BEGIN {
values = "\\s+#\\s+Default\\s+=\\s+"
option_or_values = "^(\\w" "|" values ")"
}
$0 ~ option_or_values {
result = gensub(/\[[A-Za-z0-9 ]+\]/, "", "g", gensub(/\s+=.*/, "", "1", gensub(values, "", "1")))
if (result !~ /--/) # If it's not a line with option values then it's the last entry line with just option name after which a blank line should be.
result = gensub(/$/, "\n\n", "1", result)
print result
}' "$config_path"
}
declare config_path="../assets/default_config.ini"
declare values_and_options="$(get_values_and_options "$config_path")"
print "$values_and_options"
And here is a sample from input file:
[config-meta]
#---------------------------------------------------------------
# If 'True', program starts with all config settings immediately
# If 'False', program starts with default settings immediately, ignoring any config settings
# If 'Ask', program Asks to use config settings at start. And if you have multiple configs, will ask which to use
# NOTE: This setting only applies to the primary config file ("SpamPurgeConfig.ini"), not any other configs you make
# Default = Ask -- Possible Values: True | False | Ask
use_this_config = Ask
# A short denoscription to show for this config file when asking which config file to choose
# > Examples: "Scan last 3 videos with auto smart", "Scan last video for [some phrase]"
# This ONLY matters if you have multiple config files (such as "SpamPurgeConfig2.ini", "SpamPurgeConfig3.ini", etc)
# Possible Values: Anything
this_config_denoscription = My Custom Config
I wanna just delimit my items and make output to be smth like this (default values are always put before `--`):
Ask -- Possible Values: True | False | Ask
use_this_config = Ask
Anything
this_config_denoscription
https://redd.it/zlkylm
@r_bash
Why I obtain this unexpected error? I don't understand what `awk` wants to be done? Here is my code:
#!/usr/bin/env bash
# Just leading spaces are remvoed and placeholders with square brackets.
# Entries are separated via empty blank lines.
# Anything else is being unthouched.
get_values_and_options() {
declare config_path="$1"
awk 'BEGIN {
values = "\\s+#\\s+Default\\s+=\\s+"
option_or_values = "^(\\w" "|" values ")"
}
$0 ~ option_or_values {
result = gensub(/\[[A-Za-z0-9 ]+\]/, "", "g", gensub(/\s+=.*/, "", "1", gensub(values, "", "1")))
if (result !~ /--/) # If it's not a line with option values then it's the last entry line with just option name after which a blank line should be.
result = gensub(/$/, "\n\n", "1", result)
print result
}' "$config_path"
}
declare config_path="../assets/default_config.ini"
declare values_and_options="$(get_values_and_options "$config_path")"
print "$values_and_options"
And here is a sample from input file:
[config-meta]
#---------------------------------------------------------------
# If 'True', program starts with all config settings immediately
# If 'False', program starts with default settings immediately, ignoring any config settings
# If 'Ask', program Asks to use config settings at start. And if you have multiple configs, will ask which to use
# NOTE: This setting only applies to the primary config file ("SpamPurgeConfig.ini"), not any other configs you make
# Default = Ask -- Possible Values: True | False | Ask
use_this_config = Ask
# A short denoscription to show for this config file when asking which config file to choose
# > Examples: "Scan last 3 videos with auto smart", "Scan last video for [some phrase]"
# This ONLY matters if you have multiple config files (such as "SpamPurgeConfig2.ini", "SpamPurgeConfig3.ini", etc)
# Possible Values: Anything
this_config_denoscription = My Custom Config
I wanna just delimit my items and make output to be smth like this (default values are always put before `--`):
Ask -- Possible Values: True | False | Ask
use_this_config = Ask
Anything
this_config_denoscription
https://redd.it/zlkylm
@r_bash
reddit
Unexpected `Warning: unknown mime-type for ...` from awk
Why I obtain this unexpected error? I don't understand what `awk` wants to be done? Here is my code: #!/usr/bin/env bash # Just leading...
sshto
Hi, I've just added another handy command to sshto!
Mount - it allows you to mount some folder from remote server to some local folder.
And then use this remote folder as local! Sshfs must be installed in order to use this feature.
Also Unmount and Home commands where added to cooperate with Mount.
Have fun!)
https://redd.it/zlxlcx
@r_bash
Hi, I've just added another handy command to sshto!
Mount - it allows you to mount some folder from remote server to some local folder.
And then use this remote folder as local! Sshfs must be installed in order to use this feature.
Also Unmount and Home commands where added to cooperate with Mount.
Have fun!)
https://redd.it/zlxlcx
@r_bash
GitHub
GitHub - vaniacer/sshto: Small bash noscript to manage your ssh connections. It builds menu (via dialog) from your ~/.ssh/config.…
Small bash noscript to manage your ssh connections. It builds menu (via dialog) from your ~/.ssh/config. It can not only connect but also to run commands, copy files, tunnel ports. - vaniacer/sshto
aliases for multi-word commands like
I manage my Github issues from the command line using
Is there a way to set an alias so that I can type
Is this possible?
https://redd.it/zm2x48
@r_bash
gh issue list or specific command options?I manage my Github issues from the command line using
gh issue on a regular basis, and since there are a lot of them I find myself running gh issue list -L 100 quite regularly (-L 100 increases the number of issues listed to 100).Is there a way to set an alias so that I can type
gh issue list and have it automatically add the -L 100 but not affect, for instance, gh issue create or gh issue comment? I'm sure I could set alias list="list -L 100", but I can easily see that adversely affecting other commands so I'd rather not. I'm also aware that I could simply alias this specific command to something like ghil but I'm curious and I think learning how to set aliases with multiple words could be useful for a lot of things outside of this one specific use-case.Is this possible?
https://redd.it/zm2x48
@r_bash
reddit
aliases for multi-word commands like `gh issue list` or specific...
I manage my Github issues from the command line using `gh issue` on a regular basis, and since there are a lot of them I find myself running `gh...
How to start a process in the background from a bash noscript but then kill that process when I Ctrl+C see the noscript?
I have this noscript:
#!/bin/bash
sudo nginx -t
if ! ss -l | grep 10002 > /dev/null
then
sudo nginx
else
sudo nginx -s reload
fi
python loop.py > /dev/null &
python app.py
This noscript is supposed to test the nginx config file, then check if nginx is running, if its not running, start it, if it is running reload it, then run a python noscript which is an infinite loop, then load a flask app.
If i don't add the '&' on the loop the flask app will never load because the loop will never end. However, when I press Ctrl+C on this noscript I want both loop.py and app.py to end process.
But right now only app.py ends and loop.py keeps running (I assume because it spawned a child process). How can I make it so loop.py ends when I Ctrl+C?
https://redd.it/zm42ox
@r_bash
I have this noscript:
#!/bin/bash
sudo nginx -t
if ! ss -l | grep 10002 > /dev/null
then
sudo nginx
else
sudo nginx -s reload
fi
python loop.py > /dev/null &
python app.py
This noscript is supposed to test the nginx config file, then check if nginx is running, if its not running, start it, if it is running reload it, then run a python noscript which is an infinite loop, then load a flask app.
If i don't add the '&' on the loop the flask app will never load because the loop will never end. However, when I press Ctrl+C on this noscript I want both loop.py and app.py to end process.
But right now only app.py ends and loop.py keeps running (I assume because it spawned a child process). How can I make it so loop.py ends when I Ctrl+C?
https://redd.it/zm42ox
@r_bash
found a noscript in a file i was sent and I'm wondering what exactly it does.
edited to fix format.
#!/bin/bash
filename=$1
sed -n '1~4s/^@/>/p;2~4p' $filename | awk '{print $1}' > $filename.fasta
https://redd.it/zm6c6b
@r_bash
edited to fix format.
#!/bin/bash
filename=$1
sed -n '1~4s/^@/>/p;2~4p' $filename | awk '{print $1}' > $filename.fasta
https://redd.it/zm6c6b
@r_bash
reddit
found a noscript in a file i was sent and I'm wondering what exactly...
edited to fix format. #!/bin/bash filename=$1 sed -n '1~4s/^@/>/p;2~4p' $filename | awk '{print $1}' > $filename.fasta
"type -P" vs "type -p"
As per
-P force a PATH search for each NAME, even if it is an alias,
builtin, or function, and returns the name of the disk file
that would be executed
-p returns either the name of the disk file that would be executed,
or nothing if
Could someone please provide an example when there is a difference in
https://redd.it/zm7dke
@r_bash
As per
help type output-P force a PATH search for each NAME, even if it is an alias,
builtin, or function, and returns the name of the disk file
that would be executed
-p returns either the name of the disk file that would be executed,
or nothing if
type -t NAME' would not return file'Could someone please provide an example when there is a difference in
-P vs -p output?https://redd.it/zm7dke
@r_bash
reddit
"type -P" vs "type -p"
As per `help type` output -P force a PATH search for each NAME, even if it is an alias, builtin, or function, and returns the...
How can I append an output at the end of a line on a file?
I want to append the output of the following code at the end of every line in a file
echo "$(printf "%0d" "$x" 0)$exampleString" | perl -lape '$_=pack"(B8)",@F'
I think
https://redd.it/zmh5hs
@r_bash
I want to append the output of the following code at the end of every line in a file
echo "$(printf "%0d" "$x" 0)$exampleString" | perl -lape '$_=pack"(B8)",@F'
I think
sed is the right way to go, but I just don't know how to fit all that piece of codehttps://redd.it/zmh5hs
@r_bash
reddit
How can I append an output at the end of a line on a file?
I want to append the output of the following code at the end of every line in a file echo "$(printf "%0*d" "$x" 0)$exampleString" | perl...
grep output for a file not found - How can I redirect that message to a new variable?
I have the following as an example,
​
echo -e "-------------------\nJournalctl Log Results:\n-------------------"
GREPJOURNALCTL=$( journalctl | grep $input | tail -10 )
if [ -z "$GREPJOURNALCTL" ]
then
echo -e "\n${G}No Results Found${NC}\n"
else
echo -e "\n${R}Results Found${NC}\n"
sleep 1s
echo $GREPJOURNALCTL
echo ""
fi
sleep 1s
Then I would get "grep: /var/log/dmesg: No such file or directory"
Can I redirect that to a variable or is that already is redirected to a variable with GREP\JOURNALCTL? If impossible, can I redirect the stderr message to null? I've tried adding 2>&1 /dev/null but it didn't work for me :S
https://redd.it/zmjh4y
@r_bash
I have the following as an example,
​
echo -e "-------------------\nJournalctl Log Results:\n-------------------"
GREPJOURNALCTL=$( journalctl | grep $input | tail -10 )
if [ -z "$GREPJOURNALCTL" ]
then
echo -e "\n${G}No Results Found${NC}\n"
else
echo -e "\n${R}Results Found${NC}\n"
sleep 1s
echo $GREPJOURNALCTL
echo ""
fi
sleep 1s
Then I would get "grep: /var/log/dmesg: No such file or directory"
Can I redirect that to a variable or is that already is redirected to a variable with GREP\JOURNALCTL? If impossible, can I redirect the stderr message to null? I've tried adding 2>&1 /dev/null but it didn't work for me :S
https://redd.it/zmjh4y
@r_bash
reddit
grep output for a file not found - How can I redirect that message...
I have the following as an example, echo -e "-------------------\nJournalctl Log Results:\n-------------------" ...
Creating a bash noscript that uses a python package
I am running a python [package](https://hippmapp3r.readthedocs.io/en/latest/hipp_seg.html) in my linux terminal. I would like to create a loop noscript that says to use the python package to perform a function. Currently, my workflow is like this:
source activate hippmapper
hippmapper seg_hipp -t1 participantnumber.nii.gz -o participantnumber_transformed.nii.gz
conda deactivate
This is fine if I was doing one participant, but I have 671, and potentially MANY more.
I have a working shell noscript for another process, so I am using that as a template to adapt. However, altering it to what I need doesn't work, and I am unsure why. **I am activating my python environment (that I have called hippmapper) before running the shell noscript. Should it be inside the noscript?**
#!/bin/sh
parent_folder="path/here"
for i in folder1 folder2 folder3; do hippmapper seg_hipp -t1 ${parent_folder}/${i}/${i}_1_T1W.nii.gz -o ${parent_folder}/${i}/${i}_transformed.nii.gz; done
This code above does not work.
https://redd.it/zmkt04
@r_bash
I am running a python [package](https://hippmapp3r.readthedocs.io/en/latest/hipp_seg.html) in my linux terminal. I would like to create a loop noscript that says to use the python package to perform a function. Currently, my workflow is like this:
source activate hippmapper
hippmapper seg_hipp -t1 participantnumber.nii.gz -o participantnumber_transformed.nii.gz
conda deactivate
This is fine if I was doing one participant, but I have 671, and potentially MANY more.
I have a working shell noscript for another process, so I am using that as a template to adapt. However, altering it to what I need doesn't work, and I am unsure why. **I am activating my python environment (that I have called hippmapper) before running the shell noscript. Should it be inside the noscript?**
#!/bin/sh
parent_folder="path/here"
for i in folder1 folder2 folder3; do hippmapper seg_hipp -t1 ${parent_folder}/${i}/${i}_1_T1W.nii.gz -o ${parent_folder}/${i}/${i}_transformed.nii.gz; done
This code above does not work.
https://redd.it/zmkt04
@r_bash
Grep lines from a file, that have special chars in them.
I’m trying to check existing crontab entries against a file, to ensure everything in the file is loaded in to cron.
So my function is basically:
func(){
while IFS= read -r line
do
if ! crontab -l | grep -fq “${line}”. > /dev/null 2>&1
then
return 1
fi
done < crons.file
return 0
}
The issue is that, grep reads $line as a regex pattern. I can’t put single quotes around $line to make it not read it as a regex, because then $line won’t expand.
How do I navigate this? Thanks in advance!!!
https://redd.it/zmrdgn
@r_bash
I’m trying to check existing crontab entries against a file, to ensure everything in the file is loaded in to cron.
So my function is basically:
func(){
while IFS= read -r line
do
if ! crontab -l | grep -fq “${line}”. > /dev/null 2>&1
then
return 1
fi
done < crons.file
return 0
}
The issue is that, grep reads $line as a regex pattern. I can’t put single quotes around $line to make it not read it as a regex, because then $line won’t expand.
How do I navigate this? Thanks in advance!!!
https://redd.it/zmrdgn
@r_bash
reddit
Grep lines from a file, that have special chars in them.
I’m trying to check existing crontab entries against a file, to ensure everything in the file is loaded in to cron. So my function is basically: ...