Search the Community
Showing results for tags 'bash'.
-
Bash Sourcedir script :final?
Herr.Hoefkens posted a blog entry in My Take On the State of Computing
more or less final version : lists faulty source files now . and doesnt count them in the final sourced file count. needs some testing now #!/usr/bin/env bash # ############################################################################ # # PATH: /etc/profile.d AUTHOR: Hoefkens.J@gmail.com # # # FILE: bash_sourcedir.sh 0v99 - 2023.05.22 # # ############################################################################ # function bash_sourcedir { local VERSION="0.99" local WARNING="WARNING: This File Needs to be Sourced not Executed ! "; local HELP="""${FUNCNAME[0]} [-h]|[-iqd] [DIR] [MATCH] ARGS: <DIR> Directory to source files from. <MATCH> Regex to match Files against. Globbing and Expansion follow Bash Settings OPTIONS: -h --help Show this help text -i --nocase Ignore Case when matching -q --quiet Quiet/Silent/Script, Dont produce any output -d --debug Enable xtrace for this script -w --warning Shows $WARNING RECOMENDED: Make Sourcedir availeble as a command: su -c 'cp -v ./sourcedir.sh /etc/profile.d/ EXAMPLES: Source files in ~/.config/bashrc/ that end in '.bashrc' ...and (-q) do not produce any output: sourcedir -q ~/.config/bashrc/ '.*\.bashrc' Source all files in '.env' starting with "config" case insensitive ...this inlcudes 'CONFIG.cfg' 'conFig.conf' but not 'mycfg.config' sourcedir -i .env '^config.*' Source all files in '~/.bash_aliasses/' starting with 2 numbers, ...followed by an '_'. this matches '00_file.alias' but not '99file' sourcedir ~/.bash_aliasses/ '\/[0-9]{2}_.*$' : DEFAULTS: -MATCH: '/[0-9]+[_-]*.*\.(sh|bash|bashrc|rc|conf|cfg)$' -DIR: '$PWD' """; # set -o errexit # set -o nounset function batcat () { function _bat() { local theme paging batopts theme="Monokai Extended Origin" paging="never" echo "$@" |bat --plain --paging="$paging" --theme="$theme" --language="$lang" }; local lang lang="$1" shift 1 #remove that from the args as cat doesnt need it [[ -n "$( which bat )" ]] && _bat "$@" [[ -z "$( which bat )" ]] && echo $( printf '%s' "$@" ) | $( printf '%s' "$(which cat)" ) }; function _main () { function _sourcefiles () { function _sourcefile () { FILEN="$2" FILEN=$((FILEN-ERRN)) source "$1" &>/dev/null SUCCESS="$?" [[ "$SUCCESS" == "0" ]] && _progress "$1" "$GC" 2 "$2" [[ "$SUCCESS" != "0" ]] && _failfile "$1" }; function _failfile() { ERRN=$((ERRN+1)) echo "" #newline _mask 0 "$GP" "$GS" "$GN" "$N" 1 1 "Failed :" #mask _progress "$1" "$GC" 1 "$ERRN" printf '\x1b[F' }; for CONF in $SELECTED; do I=$((I+1)); [[ -e "$CONF" ]] && _sourcefile "$CONF" "$I" ; done }; function _m () { #ANSI_m : ansi markup #~ ANSIESC [$1:INT] ; [$2:INT] m [$3:STRING] ANSIESCm (:resets to default) printf "\x1b[%s;3%sm%s\x1b[m" "$1" "$2" "$3" }; function _G () { #ANSI_G : ansi cursor to column on current line #~ ANSIESC [$1:INT] G printf "\x1b[%sG" "$1" }; function _Gm () { # COMBINES G (linepos) and m (markup) # printf statements are not needed here as they are in the functions #~printf ANSIESC $1 G ANSIESC $2 ; $3 m $4 ANSIESC m _G "$1"; _m "$2" "$3" "$4" ; #~ ANSIESC [$1:INT] G ANSIESC [$2:INT] ; [$3:INT] m [$4:STRING] ANSIESC m # _Gm printf "\x1b[%sG\x1b[%s;%sm%s\x1b[m" "$1" "$2" "$3" "$4" }; function _mask () { # | G | m | string _Gm "${1}" "${6}" "${7}" "${8}"; _Gm "${2}" 1 7 "["; _Gm "${3}" 1 7 "/"; _Gm "${4}" 1 2 "${5}"; _m 1 7 "]" }; function _progress () { #~ G m m STRING local toprint toprint=$1 while true ; do [[ ${#toprint} > 50 ]] && toprint=".../${toprint#*/*/}" [[ ${#toprint} < 51 ]] && break ; done _Gm 12 1 3 "$toprint " _Gm "$2" 1 "$3" "$4" _G 80 }; local MATCH SRC N W GP GS GC GN ERRN FILEN ; SRC=$(realpath "${1}"); [[ -n "$2" ]] && MATCH="$2" || MATCH='/[0-9]+[_-]*.*\.(sh|bash|bashrc|rc|conf|cfg)$'; I=0; SELECTED=$( find "$SRC" 2>/dev/null |grep -E "$MATCH" ); [[ -n "$SELECTED" ]] && N=$( echo "$SELECTED" |wc -l ); W="${#N}"; GP=$((80-10-W*2)) GC=$((GP+1)) GS=$((GP+W+1)) GN=$((GP+W+2)) ERRN=0 _mask 0 "$GP" "$GS" "$GN" "$N" 0 7 "Sourcing:"; _sourcefiles ; _mask 0 "$GP" "$GS" "$GN" "$N" 0 7 "Sourced :" _progress "$SRC" "$GC" 2 _Gm "$((80-5))" 1 32 "DONE" [[ "ERRN" != 0 ]] && printf '\x1b[E' echo }; local CASE SELECTED I; case "$1" in -h | --help | '') batcat help "$HELP" ;; -d | --debug) shift && set -o xtrace && ${FUNCNAME[0]} "$@" ;; -q | --quiet) shift 1 && ${FUNCNAME[0]} "$@" &> /dev/null ;; -i | --nocase) shift 1 && CASE="-i" && ${FUNCNAME[0]} "$@" ;; -w | --warning) batcat help "\x1b[1;31m$WARNING" >> /dev/stderr ;; *) _main "$@" ;; esac; unset _m _G _progress _mask _state _sourcefiles _main _cat } #make sure its sourced not executed (return 0 2>/dev/null) || sourcedir --warning -
Hello fellow tech nerds ! I've been working on a program over the past several months and I am happy to be sharing it with you all today (ง ͠° ͟ل͜ ͡°)ง !! As most of you are aware, the issue of online scalpers buying up a lot (if not all) merchandise and reselling at at ridiculous prices has been a growing issue over the past several months. I myself was stuck refreshing web-pages of major online retailers hoping that the item I wanted would come back in stock, and hoping then that I could check out in time.. This is something I know many of you must also be going through. To help me tackle the issue, I created Puppet-purchase!!! PUPPET-PURCHASE puppeteer.ico WHAT IS IT? Puppet-purchase is a bot that automates the process of purchasing an item from a few of the most popular online retailers. HOW DO YOU USE IT ? The program uses node.js. Simple clone the repository to your local machine and install npm using node.js Links: Node.js Puppet-Purchase Once you've installed npm, provide the necessary user account information. This can be done inside of the .env.userInfo file, found in scripts/< bot >/user_info/.env.userInfo Alternatively, you can run one of the test to make sure everything is working as expected. To provide the user account information when running test, export them: export TEST_USER_EMAIL= \ TEST_USER_PASSW= \ TEST_USER_LOC= \ TEST_USER_CVV= \ TEST_USER_LISTING_URL= // This is the information the program will use to login, and checkout your cart. Test do not perform the last step of the workflow - i.e they do not click on the 'place order' button. It's a perfect way of making sure that the program will perform as intended before the moment of truth. For the program to run as as expected, be sure to set up your online account with the retailer you wish to use this bot on. A list of all scripts is located in the package.json file. A far more detailed tutorial / explanation can be found in the README.md of the github repo. WHAT IS THE INTENT ? Let me start by saying, I'm fully aware that this program isn't a perfect solution to the current situation. I'm also aware that by making this publicly available to everyone, I am making it available to those who might potentially use it for unintended purpose ( intended purpose being to check out x1 item ). My main goal by creating puppet-purcahse was to help those out there who aren't able to help themselves. Those who might otherwise have to turn to buying these items from scalpers at ridiculous prices. I'm happy to report that by using this program I was able to secure my very own ps5, and that was a few months ago. With that said, I'll add: Buyers should not have to rely on programs like this one. And, The sooner that the online retail business start implementing effective solutions to bots like these, the sooner that we will all be better off. But, the fact that programs like puppet-purchase are still effective, means that retailers aren't doing the most they can to help out buyers in this position( This program is not that sophisticated at all + These business have lot of cash to pay devs). Hope this helps. - Rusti Shackleford ( DevOps engineer )
-
- combat scalping
- puppeteer
- (and 4 more)
-
#!/usr/bin/env sh READFROM=$1 MATCH=$2 COLOR=$[ 29 + 0$3 ] printf "\nPress \033[1;32m[ctrl]+[c]\033[0m to quit.\n\n" function help() { echo 'USE: $ bwatch [PATH] [STR] [INT]' echo 'PATH : file to watch' echo 'STR : string to watch for' echo 'INT : {0..16} Color (ANSI 29+)' echo ' : eg: 2 = RED 3 = GREEN ,... ' echo 'TIP: use in Terminal with miniview/minimap to quickly spot highlighted content;eg http://terminolo.gy' exit } [[ $1 == -h ]] && help tail -n 5 -f $READFROM | bat --style grid,numbers -f --pager "sed 's/$MATCH/\o033[1;${COLOR}m&\o033[0m/g'" or the oneliner: env READFROM="####" MATCH="####" COLOR="####" tail -n 5 -f $READFROM | bat --style grid,numbers -f --pager "sed 's/$MATCH/\o033[1;${COLOR}m&\o033[0m/g'" (ofc replace #### with values of your choice result :
-
Hello, I'm trying to look for how to enable Linux Autocomplete, I'm using bash shell in linux specifically arch and for some reason whenever im tying systemctl enable , enable does not autocomplete. I was wondering what would be a method of enabling Linux Autocomplete or customizing it. Thank you
-
Hello, I'm trying to use Man pages to learn about different Linux commands but it seems very verbose and intimidating for new users. Like if you search up the cmd chmod in man pages, it will give you an intimidating response for newer users, at least in my prospective and opinion on it. I'm also using the BASH shell. I think I need to be more comfortable using man pages, which is why I think I need to just master the man page entirely. Do you all have any tips for me to improve my man page reading skill? Things I know: Man -k (Search for commands and command descriptions) Man Man (man the manual page) / to search in man page Synopsis : example of command
-
Hello, I have some modules in a folder in dropbox which is downloaded in my phone. I want to add that location permanently to the PYTHONPATH so that I can call them whenever I want. But I am unable to do that. Things I tried. import sys import site site.addsitedir('the path') print(sys.path) This was only temporary. 2. In pydroid terminal.. export PYTHONPATH = "$PYTHONPATH: the path" Any help will be much appreciated. P.S: I don't want to move these files to any other folder as because I want to have a direct connection to my PC where Dropbox folder is added to the pythonpath.
-
Hi, #!/bin/bash sourceFile="file.log" targetFile="2file.log" ping="1.1.2.3" while IFS='' read -r line || [[ -n "$line" ]]; do echo "allow-hotplug wlan0" > "$targetFile" echo "iface wlan0 inet static" >> "$targetFile" echo "address 192.168.0.2" >> "$targetFile" echo "netmask 255.255.255.252" >> "$targetFile" echo "wireless-channel 6" >> "$targetFile" echo "wireless-essid grewep" >> "$targetFile" echo "wireless-mode ad-hoc" >> "$targetFile" echo "$line" >> "$targetFile" ping -q -c 5 "$ping" ping2=$? if [ "$ping2" -ne 0 ]; then break fi sed -n -e '8p' "$targetFile" done < "$sourceFile" Is there a way to echo text, at the point of break in the if statement? Thank you
-
Hi, Currently, I've got the following to produce a random 13 character string, which includes all printable ASCII characters. #!/bin/bash LIST="a A b B c C d D e E f F g G h H i I j J k K l L m M n N o O p P q Q r R s S t T u U v V w W x X y Y z Z 0 1 2 3 4 5 6 7 8 9 ! £ $ % ^ & ( ) , . / ; ' # [ ] { } : @ ~ < > \ ? * + - = \" _ |" RAMPWD=$(cat /dev/urandom | tr -dc "$LIST" | fold -w 13 | head -n 1) echo "$RAMPWD" The problem is that sometimes the output results into this: f~VfrI▒ocgU6[ which is useless for a WEP password and just doesn't work Is there any other random generator for bash that I could use and still include all printable ASCII characters. Thank you
-
Hi, I've tried the following Crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/etc/greenwich # m h dom mon dow user command */10 * * * * /etc/greenwich/gentest.sh 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) # Bash Script #!/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/etc/greenwich targetFile="testfilegen2.log" address="192.168.1.1" netmask="255.255.255.0" channel="1" essid="GreRPi" random=$(pwgen 13 -1) sudo echo "source-directory /etc/network/interfaces.d" > "$targetFile" sudo echo "auto lo" >> "$targetFile" sudo echo "auto wlan0" >> "$targetFile" sudo echo "allow-hotplug wlan0" >> "$targetFile" sudo echo "iface wlan0 inet static" >> "$targetFile" sudo echo "address $address" >> "$targetFile" sudo echo "netmask $netmask" >> "$targetFile" sudo echo "wireless-channel $channel" >> "$targetFile" sudo echo "wireless-essid $essid" >> "$targetFile" sudo echo "wireless-mode ad-hoc" >> "$targetFile" sudo echo "wireless-key s:$random" >> "$targetFile" scp testfilegen2.log pi@192.168.1.1:~/.ssh/ sudo service networking restart And cron still doesn't automatically run the bash script every 10 mins Any suggestions? Thank you
-
Hi The below bash script runs every 10 mins on L1 and within the script is meant to generate a random password, then print that into a file, which is then copied to L2. #!/bin/bash targetFile="testfilegen2.log" address="192.168.1.1" netmask="255.255.255.0" channel="1" essid="GreRPi" random=$(pwgen 13 -1) sudo echo "source-directory /etc/network/interfaces.d" > "$targetFile" sudo echo "auto lo" >> "$targetFile" sudo echo "auto wlan0" >> "$targetFile" sudo echo "allow-hotplug wlan0" >> "$targetFile" sudo echo "iface wlan0 inet static" >> "$targetFile" sudo echo "address $address" >> "$targetFile" sudo echo "netmask $netmask" >> "$targetFile" sudo echo "wireless-channel $channel" >> "$targetFile" sudo echo "wireless-essid $essid" >> "$targetFile" sudo echo "wireless-mode ad-hoc" >> "$targetFile" sudo echo "wireless-key s:$random" >> "$targetFile" sleep 1 scp "$targetFile" pi@192.168.1.1:~/.ssh/ sudo service networking restart Unfornaltey L1 doesn't seem to recieve the new password but L2 does. L1 Output pi@raspberrypi:/etc/greenwich $ cat testfilegen2.log source-directory /etc/network/interfaces.d auto lo auto wlan0 allow-hotplug wlan0 iface wlan0 inet static address 192.168.1.1 netmask 255.255.255.0 wireless-channel 1 wireless-essid GreRPi wireless-mode ad-hoc wireless-key s:she5Bie1ojoon L2 Output pi@raspberrypi:~/.ssh $ cat testfilegen2.log source-directory /etc/network/interfaces.d auto lo auto wlan0 allow-hotplug wlan0 iface wlan0 inet static address 192.168.1.1 netmask 255.255.255.0 wireless-channel 1 wireless-essid GreRPi wireless-mode ad-hoc wireless-key s:ez2eeCeich0oc Any Suggestions? Thank you
- 3 replies
-
- cron
- bash script
-
(and 4 more)
Tagged with:
-
Hi, I've currently got 2 bash scripts within crontab # m h dom mon dow command */10 * * * * /etc/greenwich/grerpi.sh */10 * * * * /etc/greenwich/newrpi.sh but it only runs the grerpi.sh bash script grerpi.sh #!/bin/bash targetFile="/etc/network/grerpi" address="192.168.1.1" netmask="255.255.255.0" channel="1" essid="GreRPi" password="/etc/greenwich/pswfile.log" random=$(pwgen 13 -1) { echo "$random" } | sudo tee "$password" > /dev/null { echo "source-directory /etc/network/interfaces.d" echo "auto lo" echo "auto wlan0" echo "allow-hotplug wlan0" echo "iface wlan0 inet static" echo "address $address" echo "netmask $netmask" echo "wireless-channel $channel" echo "wireless-essid $essid" echo "wireless-mode ad-hoc" echo "wireless-key s:$random" } | sudo tee "$targetFile" > /dev/null scp "$targetFile" pi@192.168.1.1:~/.ssh/ newpi.shi !/bin/bash targetFile="/etc/network/interfaces2" address="192.168.1.2" netmask="255.255.255.0" channel="1" essid="GreRPi" password=$(sudo cat "/etc/greenwich/pswfile.log") { echo "source-directory /etc/network/interfaces.d" echo "auto lo" echo "auto wlan0" echo "allow-hotplug wlan0" echo "iface wlan0 inet static" echo "address $address" echo "netmask $netmask" echo "wireless-channel $channel" echo "wireless-essid $essid" echo "wireless-mode ad-hoc" echo "wireless-key s:$password" } | sudo tee "$targetFile" > /dev/null sudo service networking restart Any Suggestions? Thank you
- 6 replies
-
- cron
- bash script
-
(and 4 more)
Tagged with:
-
Hi, !/bin/bash sourceFile="file.log" targetFile="/etc/network/interfaces" numLines="$(wc -l < ${sourceFile})" counter=1 lineNumber=1 if (( counter >= "$numLines" )) || [[ ! -f "${sourceFile}" ]]; then echo "invalid file" >82; exit 1 fi while [ "$counter" -le "$numLines" ]; do echo "allow-hotplug wlan0" > "$targetFile" echo "iface wlan0 inet static" >> "$targetFile" echo "address 192.168.0.2" >> "$targetFile" echo "netmask 255.255.255.252" >> "$targetFile" echo "wireless-channel 6" >> "$targetFile" echo "wireless-essid grewep" >> "$targetFile" echo "wireless-mode ad-hoc" >> "$targetFile" awk '{print "wireless-key s:",$0}' "$sourceFile" >> "$targetFile" counter=$((counter + 1)) done With the above code, how would I print a permutation, then delete it, then print the next permutation, automatically in the bash script? Thank you
-
Hi, #!/bin/bash sourceFile="file.log" targetFile="/etc/network/interfaces" numLines="$(wc -l < ${sourceFile})" counter=1 if (( counter >= "$numLines" )) || [[ ! -f "${sourceFile}" ]]; then echo "invalid file" >82; exit 1 fi while [ "$counter" -le "$numLines" ]; do echo "allow-hotplug wlan0" > "$targetFile" echo "iface wlan0 inet static" >> "$targetFile" echo "address 192.168.0.2" >> "$targetFile" echo "netmask 255.255.255.252" >> "$targetFile" echo "wireless-channel 6" >> "$targetFile" echo "wireless-essid grewep" >> "$targetFile" echo "wireless-mode ad-hoc" >> "$targetFile" counter=$((counter + 1)) sed -n '"$counter"p' "$sourceFile" >> "$targetFile" && continue done I'm trying to print each line from sourceFile to targetFile and then wanting to run another command after each line has been printed, if unsucessful delete that line, then move onto the next. I'm seriously stuck on this one and have no idea on what to do next PLEASE HELP Thank you
-
Hi, Is there a way to create a bash script, in which it will either block connection from the attacker, if so many ping requests have been received block everything, if so many requests have been received Thank you
- 4 replies
-
- brute force
- bash
-
(and 3 more)
Tagged with:
-
Hello guys! I got a request to make on something I've been struggling to figure out for a while now! I have two screens including one that I rotate quite often from landscape for everyday use to portrait for programming. However it gets quite annoying to go to the control panel and constantly switch and reposition the screen and orientation... So here is what I hope is possible to do: Is it possible to have a script (windows and/or ubuntu) that allows me to enter a keyboard shortcut to quick swap from portrait to landscape and move the relative position of the screen (if possible). I may be asking a lot but I simply do not have the skills yet to create a script of that genre. Here are some images on the screen setups I was talking about earlier. http://imgur.com/a/3msiP Thank you for your help!!!
-
So I've got a command that I had hacked together a few months back to place in my .bash_profile that essentially picks a random file from a directory, concatenates a string to it, and passes it into cowsay, and I'd say that I have it about 90% where I want it, but I was hoping that someone here could help me get that last 10%. In essence, here is the command that is currently in my .bash_profile: command ls /usr/local/share/cows/ | sort -R | head -1 | (printf " -f /usr/local/share/cows/" && cat) | (cat && echo $(fortune -a)) | xargs cowsay Essentially, it lists all of the available .cow files, sorts them randomly, picks the first one, prepends the "-f" argument along with the path to that file (forming the "cowsay -f /usr/local/share/cows/myCow.cow" piece), and then appends a random fortune to it to form something like the following: The problem with this current setup is that if the output from fortune has any single or double quotes in it, it essentially breaks and gives up like this: And I was hoping that someone better at this than me could help me out. When I switch xargs to use the -0 option, then it passes in the entire string as what the cow says, not splitting off the "-f path/to/cow.cow" piece from the rest of the fortune, and the cow just repeats *all* of it (the same thing happens if I bypass xargs entirely and pipe directly into cowsay). I've also tried putting in some custom delimiters like '-f /usr/local/share/cows/myCow.cow * fortuneOutput' and then using 'xargs -d '*'', but that doesn't seem to be working either. Help would be appreciated.
-
Hi, Is there a way to group multiple commands, which then can be executed by a single variable? variable( command1 command2 ) Any Questions? Thank you
-
Hi, i have a simple bash script that runs perfectly when executed directly, but when running it from ruby using `shellscript.sh`, some parts don't work as expected as if the script wasn't executed within the Bash shell, but some other more basic shell lacking certain features. #!/bin/bash # Parsing cli options to variables src_path=$1 dst_path=$2 log_path=$3 # Generating file listing dir_name="${src_path##*/}" file_list=$(date +%Y%m%d%H%M%S)'_'$dir_name'.log' list_dir="/home/pi/FileListings/" # Running backup sudo rsync -av --delete-during $src_path $dst_path >> $list_dir$file_list status=$? if [ $status == 0 ]; then echo $(date)" Backup of $dir_name complete. For more details, check individual logs." >> $log_path fi I suspect that the condition in the if statement isn't evaluated properly. The error message is something along the lines of "command [0: not found". This would occur in a shell which does not support this syntax. I've also tried equivalent statements, none of which worked in this case, even though ALL of them should be correct under bash... Thanks in advance Steffen
-
Hello Guys,My Recently Acquired Acer TravelMate P643-V to replace my Lenovo ThinkPad R61.This laptop was a perfect replacemet for my aging and breaking-down ThinkPad which I have been using since the last 4-5 years now.This laptop was working perfectly fine with it's i5 3360M,4GB DDR3 and Intel HD Graphics 4000 for a month until around 1-2 weeks ago,the laptop was restarting but took forever, at the "Shutting Down" screen (It is running a factory image of Acer's Windows 7 install) I force shut it off and when i turned it on it said "Starting Windows" and immediately went to "Windows is loading files" and went to the launch startup repair and if I pressed the power button for it to turn of,it would do the the same thing until i canceled the Startup Repair and At Options,clicked "Restart" and it would boot normally later.That happened again to me on the 23rd or 24th,fixed it again,and that problem didn't occur anymore,but I had a different problem,I usually never play any other game except Minecraft,afters hours of playing,it was fine,until day before yesterday,my display driver would crash and Windows would be like "The Intel HD Graphics driver for Windows 7 has crashed and successfully recovered" (or something like that) and of course my game would crash,it would happen when my game is paused when i am doing something or while playing the game itself,and happened 3 times that day all in the same hour,so i shut it down,and next day (yesterday) I was playing,it was fine again,until my battery was at 7% and windows told me to plug it in,i plug the charger in and the driver instantly crashed and crashed my game (of course),later it did'nt happen like that again,but it crashed when i was playing,and today I am telling that,any help?
-
Hi, so I'm working on a bash script to convert several .txt files in a directory into .xml. I found it was pretty tricky to accomplish that directly so i attempted .txt to .html then .html to .xml and it worked perfectly. Now, I'm still kinda new to the world of bash scripts and was wondering how I might be able to accomplish some things. The first thing is, how do i set a variable equal to the number of .txt files in a directory. Second, well, here's my pseudo code... x = [number of .txt files in directory] for i in range (x): txt2html [file number i].txt -o [file of same name].html for i in range (x): tidy -q -asxml [file number i].html >[file of same name].xml rm *.html yea, i'm not exactly sure how to do for loops, or how to convert the files in a sequence and have the output file have the same name as the original, just in a new format. Any help is appreciated!
-
Hi I keep getting the following error sed: -e expression #1, char 32: unterminated `s' command sed: -e expression #1, char 35: unterminated `s' command sed: -e expression #1, char 35: unterminated `s' command whenever I use the following bash script #! /bin/bash mailgmail="smtp\.gmail\.com:587" mailyahoo="smtp\.mail\.yahoo\.com:587" echo "Email:" read emailuse echo "Password:" read emailpass sed -i "6s/.*/root=$emailuse/" /etc/ssmtp/ssmtp.conf sed -i "25s/.*/AuthUser=$emailuse/" /etc/ssmtp/ssmtp.conf sed -i "26s/.*/AuthPass=$emailpass/" /etc/ssmtp/ssmtp.conf if [[ "$emailuse" == *"gmail"* ]]; then sed -i "10s/.*/mail=$mailgmail" /etc/ssmtp/ssmtp.conf sed -i "23s/.*/mailhub=$mailgmail" /etc/ssmtp/ssmtp.conf sed -i "28s/.*/mailhub=$mailgmail" /etc/ssmtp/ssmtp.conf elif [[ "$emailuse" == *"yahoo"* ]]; then sed -i "10s/.*/mail=$mailyahoo" /etc/ssmtp/ssmtp.conf sed -i "23s/.*/mailhub=$mailyahoo" /etc/ssmtp/ssmtp.conf sed -i "28s/.*/mailhub=$mailyahoo" /etc/ssmtp/ssmtp.conf else echo "Use another email address with yahoo or gmail" fi Thank you
-
Hi, #! /bin/bash ip="172.16.0.1" networkconf="filetext.txt" dhcpd="filetext.txt" netmask30="2" netmask29="6" netmask28="14" echo "How many raspberry pi's are on your premises?" read norpi if [[ "$norpi" -le "$netmask30" ]]; then sed -i "30s/.*/netmask 255.255.255.252/" "$networkconf" sed -i.bak "10s/$/ 255.255.255.252{/" "$dhcpd" elif [[ "$norpi" -ge 3 && "$norpi" -le "$netmask29" ]]; then sed -i "30s/.*/netmask 255.255.255.248/" "$networkconf" sed -i.bak "10s/$/ 255.255.255.248{/" "$dhcpd" elif [[ "$norpi" -ge 7 && "$norpi" -le "$netmask28" ]]; then sed -i "30s/.*/netmask 255.255.255.240/" "$networkconf" sed -i.bak "10s/$/ 255.255.255.240{/" "$dhcpd" else echo "unable" fi lastoct=${ip: -1} range="$(($lastoct + $norpi))" echo "$range" So at the moment I'm able to take the last digit of the ip and add the amount of raspberry pi's, but what I want to do know is to place the new digit, from variable 'range' and replace the last digit of 'ip' with 'range'. Any Suggestions? Thank you
-
Trying to make bash script to make handbrake encodes with CLI, but I run into a weird issue when creating folders. Creating directories .sh file mkdir test1 mkdir test2 mkdir test3 returns mkdir: cannot create directory 'test1\r': No such file or directory mkdir: cannot create directory 'test2\r': No such file or directory And test3 gets created. Same thing happens when I try to escape at EOL with \ What am I doing wrong?
-
I'm trying to encrypt my backup with GPG using asymmetric encryption, i have tried many many different lines to encrypt my backup.tar.gz file: gpg --encrypt --batch --no-tty --yes --output "backup.$(date +"%Y-%m-%d")" --recipient EMAILOFMYPGPKEY "backup.tar.gz" gpg --encrypt --batch --no-tty --yes --output "backup.$(date +"%Y-%m-%d")" --recipient EMAILOFMYPGPKEY "backup.tar.gz" gpg --set-filename "backup.$(date +"%Y-%m-%d").tar.gz" -e -r EMAILOFMYPGPKEY "backup.tar.gz" gpg -e "backup.tar.gz" --default-recipient --batch --no-tty --yes --output "backup.$(date +"%Y-%m-%d").tar.gz" gpg -e -o "backup.$(date +"%Y-%m-%d").tar.gz" --recipient EMAILOFMYPGPKEY --batch "backup.tar.gz" gpg2 -e --recipient AE86B6C7 --output "backup.$(date +"%Y-%m-%d").tar.gz.gpg" --batch --no-tty "backup.tar.gz" gpg2 --batch --no-tty --yes --output "$filename" --recipient ANOTHEREMAILOFMYPGPKEY "backup.tar.gz" echo "ASECUREPASSPHRASE" | gpg2 --passphrase-fd 0 -r EMAILOFMYPGPKEY --output "backup.$(date +"%Y-%m-$ this runs from a bash script as root, and every time the file is correctly created but gpg asks gpg: Go ahead and type your message ... pressing the ctrl+d ends by bash script, I would like for gpg to simply encrypt my file and not prompt for a message at the end. I feel like there is a simple solution but I have not managed to find it...
-
I just stumbled across the news about "Microsoft bringing full Linux Kernel to Windows 10" and from there it was all WSL this, WSL2 that and bashing on windows etc. From what I can understand, this is all to create a non-emulated, non-VM environment within windows where you can run linux commands and full software right? So is this basically then Windows counterpart for Wine on Linux? Or is it even a step further? Because from what I read, it should be easier and better compatibility to run linux stuff in WSL2, than it is to run windows software in Wine. Or have I missed something?