Prihlásiť sa Odoslať Novinky :: FAQ :: Rozšírené vyhľadávanie :: Napísali o nás :: Ankety
Main Menu
· Home
· 
· FAQ
· 
· Diskusia
· 











Main Menu
· Domov

Moduly
· AvantGo
· Downloads
· FAQ
· News
· Recommend Us
· Reviews
· Search
· Sections
· Stats
· Topics
· Top List
· Web Links
· Forum

Jazyk
Výber jazykovej mutácie:



The time now is 13.05.2024 - 11:24


Shell scripting

Post new topic Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
 
Author Message
slonik
5 Post subject: Shell scripting  PostPosted: 30.01.2005 - 20:57 #15286
Ucen


Joined: Okt 20, 2004
Posts: 561

najde sa tu niekto kto mi poradi ja si nemozem spomenut akosa to robi ...

mam configurak

#
# komentare...
#
KEYWORD parameter1 parameter2 parameter3
KEYWORD parameter.....
koniec confu

poztreboval by som nieco
ako
for riadok in /var/subor ; do
echo $riadok
urobim nieco stym riadkom bla bla bla a dalsi riadok ... az dokonca..

done;

ale tot mi nechodi...
tak som za subor dar `cat subor`
a le pootom mi to nedava riadky..ale pojednom paramete sakra kde je problem...
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
slonik
Post subject: RE: Shell scripting  PostPosted: 30.01.2005 - 21:10 #15288
Ucen


Joined: Okt 20, 2004
Posts: 561

hmmm for riadok in read; do
....
...
done < subor tot asi nebude idem skusit...
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
crux
Post subject: takto ?  PostPosted: 31.01.2005 - 19:43 #15337
Basic


Joined: Jan 01, 2004
Posts: 25

for riadok in `cat /var/subor`; do
echo $riadok
done
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
gyro
Post subject: RE: Shell scripting  PostPosted: 31.01.2005 - 19:53 #15339
Majster


Joined: Okt 22, 2003
Posts: 3321
Location: Banská Bystrica - Rudlová
Nviem ci ti toto pomoze (je to TCSH) :

Code: › #### Registracia uzivatelov ...
set     UsersSubnetFiles = `ls $RegFiles*.users | cut -d "/" --field 4 | cut -d "." --field 1 ` ;
foreach  UsersSubnet  ( $UsersSubnetFiles ) ;
#  printf "Uzivatel segment siete: 192.168.$UsersSubnet.0 \n" ;
# @ RegisteredIPUsers ++
  set NetworkUsers = `cat $RegFiles$UsersSubnet.users` ;
    foreach NetworkUser ( $NetworkUsers ) ;
      @ RegisteredIPUsers ++
      # Sem ide povolenie IP adries na sieti
       iptables -A FORWARD -s 192.168.$UsersSubnet.$NetworkUser -j ACCEPT ;
       iptables -A FORWARD -d 192.168.$UsersSubnet.$NetworkUser -j ACCEPT ;
       iptables -A INPUT -s 192.168.$UsersSubnet.$NetworkUser -j ACCEPT ;
       iptables -A INPUT -d 192.168.$UsersSubnet.$NetworkUser -j ACCEPT ;
      end ;
end ;


Last edited by gyro on 31.01.2005 - 20:03; edited 1 time in total
 
 View user's profile Send private message Send e-mail Visit poster's website ICQ Number 
Reply with quote Back to top
gyro
Post subject: RE: Shell scripting  PostPosted: 31.01.2005 - 19:58 #15340
Majster


Joined: Okt 22, 2003
Posts: 3321
Location: Banská Bystrica - Rudlová
V premennej RegFiles mam definovanu cestu k suborom kde mam nazvy asi takto 1.users, 2.users, 3.users,... kde cisla suborou su podsiete a obsahuju konecne cisleo stanice deta pri cat 1.users napriklad: 1,2,3,4,5,....

Inkrementacia premennych je len kvoli statistike FW.
 
 View user's profile Send private message Send e-mail Visit poster's website ICQ Number 
Reply with quote Back to top
slonik
Post subject: Re: takto ?  PostPosted: 02.02.2005 - 07:42 #15393
Ucen


Joined: Okt 20, 2004
Posts: 561

crux wrote: ›for riadok in `cat /var/subor`; do
echo $riadok
done

toto mi robilo ze kady parameter bol ako samostatny riadok hmm toto nie...
ale dik...

for read riadok parm 1 parm2 parm 3 ; do
echo $riadok;
done < subor


tusim takto nejako sakra zase som zabudol ako presne to riesi..
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
floppy
Post subject: RE: Re: takto ?  PostPosted: 12.02.2005 - 20:23 #15926
Basic


Joined: Mar 03, 2003
Posts: 423
Location: Nitra
#!/bin/sh

zoznam je subor
i je premenna v subore, ktora obsahuje ip,mac

for i in `cat zoznam`
do
ip=`echo $i | cut -f1 -d,`
mac=`echo $i | cut -f2 -d,`
iptables -A input -s $ip -m mac --mac $mac -j ACCEPT
done
 
 View user's profile Send private message Visit poster's website ICQ Number 
Reply with quote Back to top
slonik
Post subject: RE: Shell scripting  PostPosted: 12.02.2005 - 21:24 #15928
Ucen


Joined: Okt 20, 2004
Posts: 561

hmm dik ale to co som napisal vyssie chodi

je to cistejsie a hlavne je to rychjsie...
ako forkovat child shelll a a vnom cut
takto som to vedel spravit ale pamatal som si ze nejaka kuleha tam
je preto mi to neslo .... mal som tam ";" navyse...

teraz mam iny problem ...
kedze som zistil ze toto distro ma "dialog"
tak som sa rozhodol prepisat menu na take ncurses aby to bolo pekne
tie menu typu stlac 1 ,2 ,3 .... pod...... nic moc aj ked to chodi s dumb term-om...... ale user friendly tak user friendly...


parsujem ten configurak vyberam id, a mena userov
pripajam to so retazca
aby vzniklo.....
"id1" "user1" "id2" "user2" az posledny....
lebo....
#syntax dialog
# dialog --menu <text> <sirka> <vyska okna> <pocet poloziek> #<tag1> <item1> ......<tagX> <itemX>


vysledok.... je v premennej ....
string=" '1' 'Username1' '2' 'Username2' ";
#vysledok by mal byt '1' 'Username1' '2' 'Username2'
dialog --menu "Vyber lusera" 70 18 10 $string

bum nejde to
ale takto to ide Sad
exec dialog --menu "Vyber lusera" 70 18 10 $string
ale uz sa nevratim do sheluu z ktoreho som to spustil
kde je sakra problem...

aj takto to ide ale to nexcem zapisovat na disk..
echo "dialog --menu 'Vyber lusera' 70 18 10 $string" >subor
chmod +x subor
run ...subor

ale to je sproste takto robit ....
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
slonik
Post subject: RE: Shell scripting  PostPosted: 12.02.2005 - 22:36 #15934
Ucen


Joined: Okt 20, 2004
Posts: 561

problem solved na konci riadka nebola ";"
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
All times are GMT
Post new topic Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
 
Jump to:  

Powered by PNphpBB2 © 2003-2005 The PNphpBB Group
Credits

(C) SKFree 2002-2010: Powered by POSTNUKE. Môžete prebera? naše správy vo formáte XML(RSS)