![]() |
|
|
google unix.com
|
|||||||
| Fóruns | Registar | Fórum Regimento | Ligações | Álbuns | FAQ | Lista deputados | Calendário | Pesquisa | Today's Posts | Mark Forums Read |
| Programação Shell Script e Post perguntas sobre ksh, CSH, SH, BASH, Perl, PHP, SED, Awk e outros scripts shell e shell scripts línguas aqui. |
Mais UNIX e Linux Fórum Tópicos Você pode achar Helpfull
|
||||
| Fio | Thread Starter | Fórum | Respostas | Última postagem |
| Mover Comando e saída estatuto problema | visingha | Programação Shell Script e | 10 | 09-13-2008 09:08 |
| Mover Comando e saída estatuto problema | visingha | UNIX para Dummies Perguntas & Respostas | 1 | 09-12-2008 03:14 |
| saída estado executando java classpath no shell Unix | mmcds | Alto Nível de programação | 2 | 08-02-2007 11:06 |
| verificar status de saída um shell script | kdipankar | Programação Shell Script e | 2 | 05-09-2006 02:08 |
| Problema com saída estado | diganta | Programação Shell Script e | 1 | 09-28-2005 09:34 |
|
|
Linkback | Thread Tools | Pesquisar este Thread | Rate Thread | Display Modes |
|
||||
|
sh recursivo sub-shell saída estatuto problema
Oi
Tenho o seguinte diretório estrutura criada no meu diretório local: --Estou a tentar detectar a saída de um estado recursivos função que estou a correr como um sub-shell. Tenho listadas abaixo parte do arquivo shell script que estou executando a sua desculpa ... ainda um pouco longo fôlego: -- Código:
#!/bin/sh
addFile()
{
fileName="${1##*/}" # Extract filename from path.
if [ $fileName == "phil" ]
then
return 1 #Kick off error...
else
return 0
fi
}
addCommitFiles()
{
# Traverse to database directory or below
cd "$topDir/$1"
if [ $? != 0 ]
then
echo "topDir error $topDir/$1"
exit 1 # Treat as fatal error.
fi
# List all files/dirs in this directory.
ls | while read i
do
# Check if directory.
if [ -d "$i" ]
then
# Pass in full relative path to topDir.
( addCommitFiles "$1/$i" )
ret1=$? # This is never non-zero???
echo "RET=$ret1 != 1"
if [ $ret1 != 0 ]
then
echo "ERR2???"
exit 1 # Treat as fatal error.
fi
echo "ERR3"
else
echo "${rootDir}/$1/${i}"
addFile "$1/$i"
if [ $? != 0 ]
then
echo "ERR1"
exit 1 # We get this error and would exoect
fi
fi
done
exit 0
}
# Main
usrNam="XXX"
topDir=`pwd`
rootDir="./"
(addCommitFiles "./$usrNam")
if [ $? != 0 ]
then
echo "ERROR"
else
echo "OK"
fi
XXX arquivos xyz dir \u003d YYY arquivos x1 y1 z1 dir \u003d ZZZ arquivos phil x2 y2 z2 Quando eu executar o script de shell que recebo a saída: -- .//./ XXX / a .//./ XXX / b .//./ XXX / c .//./ XXX/YYY/x1 .//./ XXX/YYY/y1 .//./ XXX/YYY/z1 .//./ XXX / YYY / ZZZ / phil Err1 RET \u003d 0! \u003d 1 ERR3 RET \u003d 0! \u003d 1 ERR3 OK O que eu não entendo é por isso que não recebem o "ERR2 ???". Recebo Err1 fora porque addFile retorna 1, mas eu estava esperando para obter ERR2? "Fora porque o subshell então sai com saída 1. Eu obviamente estou faltando alguma coisa aqui e seria muito grato se alguém pode ajudar? Obrigado Última edição por philp; em 01/07/2009 05:58.. Motivo: Adicionado Código tags |
| Marcadores |
| Thread Tools | Pesquisar este Thread |
| Display Modes | Esta taxa Thread |
|
|