[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]

BASH SCRIPTING THREAD

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: 9
Thread images: 2

File: Sgtbash.gif (52KB, 400x300px)
Sgtbash.gif
52KB, 400x300px
Let's make a bash script together anonymous.

I'm going to start off, if you can think of better ways to do this please post! Hints and tips are good too.

OK, so what should our script do? Let's start with generating a random IP address. Once we've got that down, we'll decide what to do with it. (cont)
>>
>>58329221
OK, so what I'll be using to get some random numbers is a commnand that is probably in all your bash shells called shuf. Let's tell shuff to spit out some random numbers between 1 and 255. 4 of them to be exact.
$ shuf -i 1-255 -n 4
42
140
206
41

Well it's a start, but the numbers aren't very usable like that.
>>
>>58329272
So what we want to do is get all the numbers on a line, with dots inbetween them.

I'll use tr.
The reason the numbers are on different lines is there is an invisible character that tells the terminal to go to a new line. It's symbolised by this "\n".

So we use tr to find these characters and replace them. We'll be doing this by putting a pipe symbol at the end of the last command to pipe the output into tr, then handling it.

$ shuf -i 1-255 -n 4|tr '\n' "."
180.181.147.18.

Now that's a lot more usable, but it unfortunately has the trailing dot after the last number, making it unusable in other scripts. And the four different fields fo the IP can be 1 or 3 characters, so you can't just slap a character specific limit on it. What would you do?
>>
File: trudeau_rocky.webm (2MB, 1280x720px) Image search: [Google]
trudeau_rocky.webm
2MB, 1280x720px
>>58329347
What I'm going to do is instead of straight away replacing the newlines with dots, replace them with spaces. Then feed them into awk, so I can treat each space seperated field as a variable to echo, and stick the dots inbetween them then.
$ shuf -i 1-255 -n 4|tr '\n' " "|awk {'print $1 "." $2 "." $3 "." $4 '}
174.73.231.143

Hey, it works! So now we have a randomly generated IP address.

What do you think should be done with it /g/?

Can you tear yourself away from your lame consumerist advertising threads? Would you rather talk about headphones?
>>
You make a thread and ask people to write a script together and then you samefag the fucking thing yourself
>>
>>58329781
I was hoping people suggest better ways to do things. Anyway I stopped now until I get some more input because I think this is pointless. I'm betting zero people here know how to bash script further than ls and rm -rf / --no-preserve-root
>>
I'm interested... Just don't know bash...
>>
I'm making an email marketing bash script.

- Scrapes a target website for emails.
- Scrapes relevant info that I can use to personalize the email, their FB presence, Twitter followers, how often they post, if they have a blog, etc.
- Sends mail to all emails scraped introducing myself and asking if they are the right person to talk to.
>>
>>58330591
You're a faggot dude. I hate spammers.

How you doing it, wget + grep?
Thread posts: 9
Thread images: 2


[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.