[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
Void's Forums • View topic - Where's the error

Where's the error

Discuss Applications

Where's the error

Postby Basher52 » Wed Jun 22, 2011 12:17 am

User avatar
Basher52
guru
guru
 
Posts: 907
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: Where's the error

Postby Void Main » Wed Jun 22, 2011 12:28 am

User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Re: Where's the error

Postby Basher52 » Wed Jun 22, 2011 1:26 am

hmm, so you can't have an 'if' inside another as I do here?
I'll color the "if's" etc so you can see what I'm thinking of.
Same color means that they are related.
(Seems I can't use the 'code' tag with colors :P )


#!/bin/bash

for subnet in $(/sbin/ifconfig | awk '/inet addr:/ && ! /127.0.0.1/{sub(/inet addr:/,""); sub(/\.[0-9]+\.[0-9]+$/,"",$1); print $1}')
do
if [ grep -qw $subnet ./subnet.adm ] ; then
parted /dev/sda rm 3
parted /dev/sda rm 2
parted /dev/sda rm 1

if [ `zisview ComputerName|grep -c BK` != 0 ]; then
zisedit -c
fi
img -restore -proxy bas-mdt.zmg

if [ test -e /proc/acpi/battery/*/state ] ; then
img -restore -proxy adm-laptop.zmg ; /bin/eject /dev/cdrom ; reboot -f
else
img -restore -proxy adm-desktop.zmg ; /bin/eject /dev/cdrom ; reboot -f
elif [ grep -qw $subnet ./subnet.utb ] ; then
parted /dev/sda rm 3
parted /dev/sda rm 2
parted /dev/sda rm 1

if [ `zisview ComputerName|grep -c BK` != 0 ]; then
zisedit -c
fi
img -restore -proxy bas-mdt.zmg

if [ test -e /proc/acpi/battery/*/state ] ; then
img -restore -proxy utb-laptop.zmg ; /bin/eject /dev/cdrom ; reboot -f
else
img -restore -proxy utb-desktop.zmg ; /bin/eject /dev/cdrom ; reboot -f
else echo Unknown subnet: $subnet. Script canceled and eagerly awaits instructions...
fi
done
User avatar
Basher52
guru
guru
 
Posts: 907
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: Where's the error

Postby Basher52 » Wed Jun 22, 2011 1:28 am

DOH!!!
Just found it, I forgot to 'fi' the 'if' statement that has the 'else'.

I'm a bit confused with all the examples I've seen when to use 'fi'
Sometimes they use it and sometimes they don't, but in this case I need to use it to "quit" the 'if' before the continuation of the previous one.
User avatar
Basher52
guru
guru
 
Posts: 907
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: Where's the error

Postby Void Main » Wed Jun 22, 2011 2:44 am

User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Re: Where's the error

Postby Basher52 » Wed Jun 22, 2011 4:18 am

k, got it :)
User avatar
Basher52
guru
guru
 
Posts: 907
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE


Return to Applications

Who is online

Users browsing this forum: No registered users and 1 guest

cron