[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] Redirect I/O
From: |
Breno Moiana |
Subject: |
Re: [shell-script] Redirect I/O |
Date: |
Thu, 26 Nov 2009 16:10:15 -0200 |
Voce pode isolar o "quente" do script dentro de uma função, e chamar essa
função com o tee, assim:
<script>
#!/bin/ksh
function meushell {
echo "um dois tres"
ls -l /home/user/um.ksh
}
meushell | tee meulog.log
</script>
Resultado:
$ ./um.ksh
um dois tres
-rwxr-xr-x 1 user group 110 Nov 26 12:07 /home/user/um.ksh
$cat meulog.log
um dois tres
-rwxr-xr-x 1 user group 110 Nov 26 12:07 /home/user/um.ksh
Breno.
--
"If you're gonna eat three times a day to the day that you die, why not be
good at it?
It will save you money, it will more than likely make you healthier... and
you'll be happier!"
Jamie Oliver
2009/11/26 thiagomz <address@hidden>
>
>
> thiagomz escreveu:
> > Pessoal,
> >
>
> Vamos la pessoal...
>
> ### Conteudo do script
>
> cnt-prx-01:~# cat meushell.sh
> #!/bin/bash
> ### inicio do shell
> exec > meushell.log
> exec 2>&1
>
> echo Conteudo da Pasta
> ls -l
>
> #### fim do shell
>
> ----
>
> ### Executando o script, note que nao recebo nada na tela...
>
> cnt-prx-01:~# ./meushell.sh
> cnt-prx-01:~#
>
> ### Log Gerado, notem que toda saida do shell, qualquer comando que eu
> colocar nele, vai para o log....
>
> cnt-prx-01:~# cat meushell.log
> Conteudo da Pasta
> total 8
> -rw-r--r-- 1 root root 18 Nov 26 14:58 meushell.log
> -rwxr--r-- 1 root root 74 Nov 26 14:58 meushell.sh
>
> O que eu queria é um plus nesse script, alem dele jogar toda saida do
> shell para o meushell.log ele tb coloca-se na tela.
>
> Entenderam ???
>
>
> --
> Att./Regards,
>
> Thiago Zerbinato
> OCP DBA 8i/10g
> http://www.thiagomz.com/
> Ribeirao Preto/SP - Brazil
>
>
>
[As partes desta mensagem que não continham texto foram removidas]
Re: [shell-script] Redirect I/O, thiagomz, 2009/11/26
- Re: [shell-script] Redirect I/O,
Breno Moiana <=