Automatic Shutdown
1
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?
2
Name:
Anonymous
2008-04-26 6:57
Anyone has any idea on how to do this?
Yep.
3
Name:
Anonymous
2008-04-26 7:02
Could you also please explain how -_-'
4
Name:
Anonymous
2008-04-26 7:03
Using COMPUTER SCIENCE
5
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.
6
Name:
Anonymous
2008-04-26 7:28
(if (> (+ upload-total download-total) (* 100 1024 1024)) (shutdown))
7
Name:
Anonymous
2008-04-26 7:33
8
Name:
Anonymous
2008-04-26 10:03
>>5
Watch the faggot not get it right because his interface is called something other than eth1.
9
Name:
Anonymous
2008-04-26 10:08
>>8
That was my intention. Now you've warned him.
10
Name:
Anonymous
2008-04-26 10:29
>>5
init 0 Doesn't work on all Unices.
Use
shutdown -h now.
11
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.
12
Name:
Anonymous
2008-04-26 10:37
Holy fuck Ubanto 8.04 is out!!
13
Name:
Anonymous
2008-04-26 13:19
You can always hire few niggers instead, if
>>5 's advice doesn't help.
14
Name:
Anonymous
2008-04-26 13:40
Use haxmyanus now
15
Name:
HAX MY ANUS MEME FAN
2008-04-27 21:03
16
Name:
Anonymous
2008-04-27 22:53
17
Name:
Anonymous
2008-04-29 12:15
>>5
Ok, this doesn't work (and yes,I changed it to my eth)
18
Name:
Anonymous
2008-04-29 19:11
19
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.
20
Name:
Anonymous
2008-04-29 19:50
>>19
You may prefer to start a new thread
in /pr/
21
Name:
Anonymous
2008-04-29 19:55
22
Name:
Anonymous
2008-04-29 20:18
23
Name:
Anonymous
2008-04-29 21:06
The cancer is now terminal.
24
Name:
Anonymous
2008-04-29 23:59
>>19
You
(set-face-foreground 'hl-line-face "red").
25
Name:
Anonymous
2008-04-30 6:27
>>24
I love you bampu pantsu
26
Name:
Anonymous
2008-04-30 9:18
bampu pantsu
27
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.
28
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?
29
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
30
Name:
Anonymous
2008-05-01 11:10
DON'T HELP HIM!
31
Name:
Anonymous
2008-05-01 11:32
>>30
5 here. Alright. I was tempted but this is getting ridiculous.
32
Name:
Anonymous
2008-05-01 12:43
33
Name:
Anonymous
2008-05-01 13:29
wget -r something && shutdown -h now
34
Name:
Anonymous
2008-05-01 20:50
>>33
What if the download fails?
35
Name:
Anonymous
2008-05-01 21:01
>>34
Then don't shut down. Duh.
36
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 :)
37
Name:
Anonymous
2008-05-02 7:03
>>36
Try removing the invalid arithmetic operators.
38
Name:
Anonymous
2008-05-02 7:05
>>36
/bin/bash --version please
39
Name:
Anonymous
2008-05-02 7:12
>>38
It states
hax my anus v1.34
40
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