DarkHipno Posted May 18, 2008 at 02:21 PM Report Share #185850 Posted May 18, 2008 at 02:21 PM Boas tardes, não sei se é bem aqui que tenho de postar a minha duvida, também procurei mas não encontrei nada no fórum que me podesse ajudar. É o seguinte necessito de um script que procure num ficheiro por exemplo o ficheiro de configuração do apache: httpd.conf e que localiza-se a linha DirectoryIndex e que a substitui-se por "DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.php4 index.pl". Isto é para integrar num ficheiro de instalação/configuração automatica do apache que estou a fazer para um projecto de aptidão tecnica (PAT). Cumprimentos... Link to comment Share on other sites More sharing options...
Serafim Posted May 18, 2008 at 05:52 PM Report Share #185886 Posted May 18, 2008 at 05:52 PM Boas. Não sei se é bem isto que pretendes, nem se é o melhor modo de o fazer. Mas tá aqui a minha ajuda. #!/bin/bash nfile1="/etc/httpd/httpd.conf" nfile2="httpd.conf" string="DirectoryIndex" replace=" DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.php4 index.pl" cline=`cat $nfile1 | grep -n $string | grep -v "#" | cut -f1 -d:` let cline=$cline-1 head -n$cline $nfile1 > $nfile2 echo $replace >> $nfile2 let cline=$cline+1 let cline=`wc -l $nfile1 | tr ' ' '#' | cut -f1 -d'#'`-$cline tail -n$cline $nfile1 >> $nfile2 mv $nfile2 $cfile1 Link to comment Share on other sites More sharing options...
slack_guy Posted May 18, 2008 at 06:46 PM Report Share #185895 Posted May 18, 2008 at 06:46 PM E não pode ser Perl? $ perl -p -i -e 's/DirectoryIndex/DirectoryIndex index\.html index\.htm index\.shtml index\.cgi index\.php index\.php3 index\.php4 index\.pl/g' /etc/httpd/httpd.conf :q :q! :wq :w :w! :wq! :quit :quit! :help help helpquit quit quithelp :quitplease :quitnow :leave ^X^C ^C ^D ^Z ^Q QUITDAMMIT Link to comment Share on other sites More sharing options...
DarkHipno Posted May 18, 2008 at 09:25 PM Author Report Share #185951 Posted May 18, 2008 at 09:25 PM E não pode ser Perl? $ perl -p -i -e 's/DirectoryIndex/DirectoryIndex index\.html index\.htm index\.shtml index\.cgi index\.php index\.php3 index\.php4 index\.pl/g' /etc/httpd/httpd.conf Realmente slack_guy funciona melhor em perl. Obrigado a ambos pela ajuda 😉 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now