Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Automatic Shutdown

Name: Anonymous 2008-04-26 6:53

I need to find a way to shut down my Linux PC (Ubuntu 8.04 Server) after it has up & downloaded 100MB.
Anyone has any idea on how to do this?

Name: Anonymous 2008-04-26 6:57

Anyone has any idea on how to do this?
Yep.

Name: Anonymous 2008-04-26 7:02

Could you also please explain how -_-'

Name: Anonymous 2008-04-26 7:03

Using COMPUTER SCIENCE

Name: Anonymous 2008-04-26 7:26

#!/bin/bash
RX=`ifconfig | grep -A 6 eth1 | grep "RX bytes" | sed -e "s/\s*RX bytes:\([0-9]*\).*/\1/g"`
TX=`ifconfig | grep -A 6 eth1 | grep "TX bytes" | sed -e "s/.*TX bytes:\([0-9]*\).*/\1/g"`
if [ $RX -ge 104857600 -o $TX -ge 104857600 ]
then
    init 0
fi



Put it in root's crontab.

Name: Anonymous 2008-04-26 7:28

(if (> (+ upload-total download-total) (* 100 1024 1024)) (shutdown))

Name: Anonymous 2008-04-26 7:33

>>5 DON'T HELP HIM!!!

Name: Anonymous 2008-04-26 10:03

>>5
Watch the faggot not get it right because his interface is called something other than eth1.

Name: Anonymous 2008-04-26 10:08

>>8
That was my intention. Now you've warned him.

Name: Anonymous 2008-04-26 10:29

>>5
init 0 Doesn't work on all Unices.
Use shutdown -h now.

Name: Anonymous 2008-04-26 10:35

>>10
Ok, thanks.

However if that's the case on a particular system, chances are that the output of ifconfig is also quite different, which breaks the grep/sed stuff as well.

Name: Anonymous 2008-04-26 10:37

Holy fuck Ubanto 8.04 is out!!

Name: Anonymous 2008-04-26 13:19

You can always hire few niggers instead, if >>5's advice doesn't help.

Name: Anonymous 2008-04-26 13:40

Use haxmyanus now

Name: HAX MY ANUS MEME FAN 2008-04-27 21:03

>>14
I like your style.

Name: Anonymous 2008-04-27 22:53

>>10
s/-h/-p/

Name: Anonymous 2008-04-29 12:15

>>5
Ok, this doesn't work (and yes,I changed it to my eth)

Name: Anonymous 2008-04-29 19:11

>>17
LOL!!!!!!!1

Name: Anonymous 2008-04-29 19:23

EMACS question: how the hell do I set faces? Say I've been provided with a hl-line-face, how to set it to "red"? (setq 'hl-line-face "red") gives me a type error.

Name: Anonymous 2008-04-29 19:50

>>19
You may prefer to start a new thread in /pr/

Name: Anonymous 2008-04-29 19:55

>>20
No, I'd rather not.

Name: Anonymous 2008-04-29 20:18

>>21
Then sage

Name: Anonymous 2008-04-29 21:06

The cancer is now terminal.

Name: Anonymous 2008-04-29 23:59

>>19
You (set-face-foreground 'hl-line-face "red").

Name: Anonymous 2008-04-30 6:27

>>24
I love you bampu pantsu

Name: Anonymous 2008-04-30 9:18

bampu pantsu

Name: Anonymous 2008-04-30 14:26

>>17
This was not meant as a working script for you to kopipe but rather an idea how to do it and some hints on how to build your own script.

Name: Anonymous 2008-05-01 6:07

Ok, I currently have this:

#!/bin/bash
RX=`ifconfig eth0 | grep "RX bytes" | sed -e "s/\s*RX bytes:\([0-9]*\).*/\1/g"`
TX=`ifconfig eth0 | grep "TX bytes" | sed -e "s/.*TX bytes:\([0-9]*\).*/\1/g"`
echo $RX
echo $TX

When I try this:
Total=$RX+$TX
echo $Total

It gives me this error:
: command not found4: [Here is the $RX]

So I need to change the variable to an integer, can someone please tell me how to do this?

Name: Anonymous 2008-05-01 8:24

>>28
/prog/ is not your personal search engine
look around for one of the FIVE MILLION tutorials on shell scripting

Name: Anonymous 2008-05-01 11:10

DON'T HELP HIM!

Name: Anonymous 2008-05-01 11:32

>>30
5 here. Alright. I was tempted but this is getting ridiculous.

Name: Anonymous 2008-05-01 12:43

>>28
Total=$((RX + TX))

Name: Anonymous 2008-05-01 13:29

wget -r something && shutdown -h now

Name: Anonymous 2008-05-01 20:50

>>33
What if the download fails?

Name: Anonymous 2008-05-01 21:01

>>34
Then don't shut down. Duh.

Name: Anonymous 2008-05-02 6:58

#!/bin/bash
RX=`ifconfig eth0 | grep "RX bytes" | sed -e "s/\s*RX bytes:\([0-9]*\).*/\1/g"`
TX=`ifconfig eth0 | grep "TX bytes" | sed -e "s/.*TX bytes:\([0-9]*\).*/\1/g"`
echo RX: $RX
echo TX: $TX
Total=$(($RX + $TX))
echo Total: $Total

Gives me as output:

RX: 42507
TX: 51532
") 51532 error: invalid arithmetic operator (error token is "
Total:

>>33
Thanks for trying to help, but it's not exactly what I need :)

Name: Anonymous 2008-05-02 7:03

>>36
Try removing the invalid arithmetic operators.

Name: Anonymous 2008-05-02 7:05

>>36
/bin/bash --version please

Name: Anonymous 2008-05-02 7:12

>>38
It states
hax my anus v1.34

Name: Anonymous 2008-05-02 7:13

Works for me, just pasted into terminal. Something's out of date with your system if $((...)) doesn't work for arithmetic.

opteron:~ # RX=`ifconfig eth0 | grep "RX bytes" | sed -e "s/\s*RX bytes:\([0-9]*\).*/\1/g"`
opteron:~ # TX=`ifconfig eth0 | grep "TX bytes" | sed -e "s/.*TX bytes:\([0-9]*\).*/\1/g"`
opteron:~ # echo RX: $RX
RX: 35568898031
opteron:~ # echo TX: $TX
TX: 32304412269
opteron:~ # Total=$(($RX + $TX))
opteron:~ # echo Total: $Total
Total: 67873310300

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List