[+] Skrypt bash - Instrukcja warunkowa if
: 10 czerwca 2011, 13:04
Witam,
mam problem se skryptem, który napisałem do obsługi oprogramowania CFD.
Kod skryptu:
Gdy uruchamiam go na moim komputerze zwraca błędy w warunkach IF:
Co ciekawe, na klastrze działa bez problemu. Powoduje to straszne zamieszanie jeżeli chodzi o pracę z tym plikiem.
Wygląda na to, jakbym miał jakiś problem z interpreterem BASH. Nawet przeinstalowałem pakiety:
Niestety to nie pomogło. Mój plik .bashrc wygląda następująco:
Jakiś czas temu (około miesiąca) skrypt działał bez najmniejszych problemów.
Specyfikacja systemowa:
uname -a
Debian Testing “Wheezy” - aktualizowany gdy tylko pojawiają się poprawki.
source.list
Bardzo proszę o pomoc, nie mam zielonego pojęcia co się u mnie namieszało. Z góry dziękuję za wszelkie konstruktywne uwagi.
Pozdrawiam
Alth
mam problem se skryptem, który napisałem do obsługi oprogramowania CFD.
Kod skryptu:
Kod: Zaznacz cały
#!/bin/sh
ver="ver: 1.0 09.06.2011" # version of the script
backup="yes" # make backup of current files
test_installation="yes" # test Edge binary files
PBS="yes" # linux cluster PBS queuing
edge_path=/home/krzych/Programy/edge-solver-5.2.0
case_name="case_name" # name of current case
mesh_name="mesh_name" # name of current mesh
job_path=`pwd` # job path of current case
np=1 # number of procesors calculations
# =1 for sequential calculation
# >1 for parallel calculation
filetest() {
if [ ! -f $1 ]
then
echo "** File " $1 "NOT found !!!! **"; error=1;
else
echo "** File " $1 "found **";
fi
}
if [[ $backup == "yes" ]]
then
echo ""
echo "################################# Backup ##################################"
echo ""
time=`date +%Y-%m-%d`
mkdir backup_$time
pwd
cp -vr * backup_$time
cd backup_$time
rm -fr backup_$time
cd ..
tar -czf backup_$time.tgz backup_$time
rm -fr backup_$time
echo ""
echo "############################## End of Backup ##############################"
echo ""
else
echo ""
echo "############################# Skipping Backup #############################"
echo ""
fi
if [[ $test_installation == "yes" ]]
then
echo ""
echo "######################## Testing your Installation ########################"
echo ""
if [ bound ] || [ -x $edge_path/bin/bound ]
then
echo "Boundary conditions subroutine: OK"
else
echo "Your PATH environment variable must be set to the installation directory
in order to run Edge 5.2."
exit
fi
if [ preprocessor ] || [ -x $edge_path/bin/preprocessor ]
then
echo "Preprocessor subroutine: OK"
else
echo "Your PATH environment variable must be set to the installation directory
in order to run Edge 5.2."
exit
fi
if [ edge_run ] || [ -x $edge_path/bin/edge_run ]
then
echo "Sequential solver: OK"
else
echo "Your PATH environment variable must be set to the installation directory
in order to run Edge 5.2."
exit
fi
if [ edge_mpi_run ] || [ -x $edge_path/bin/edge_mpi_run ]
then
echo "Parallel solver: OK"
else
echo "Your PATH environment variable must be set to the installation directory
in order to run Edge 5.2."
exit
fi
echo ""
echo "List the contents of an FFA-format file:"
ffalist -n $edge_path/share/examples/edge/rae_euler/mesh.bmsh
echo ""
echo "############################### End of test ###############################"
echo ""
fi
echo ""
echo "################################ File check ###############################"
echo ""
filetest $case_name.aboc
filetest $case_name.ainp
filetest $case_name.bedg
filetest $case_name.bmsh
echo ""
echo "############################ End of file check ############################"
echo ""
if [[ $PBS == "yes" ]]
then
if [[ $np == 1 ]]
then
cd $PBS_O_WORKDIR
pwd
cp -vr * $TMPDIR
cd $TMPDIR
pwd
cat $PBS_NODEFILE
echo " Sequential computation with $np processors"
edge_run $case_name.ainp
mkdir $PBS_O_WORKDIR/results
cp -vr * $PBS_O_WORKDIR/results
else
cd $PBS_O_WORKDIR
pwd
cp -vr * $TMPDIR
cd $TMPDIR
pwd
cat $PBS_NODEFILE
echo " Parallel computation with $np processors"
edge_mpi_run $case_name.ainp $np
mkdir $PBS_O_WORKDIR/results
cp -vr * $PBS_O_WORKDIR/results
fi
else
if [[ $np == 1 ]]
then
echo " Sequential computation with $np processors"
edge_run $case_name.ainp
else
echo " Parallel computation with $np processors"
edge_mpi_run $case_name.ainp $np
fi
fi
Kod: Zaznacz cały
krzych@debian:~/Skrypty$ ./run_edge_solver.sh
./run_edge_solver.sh: 50: [[: not found
############################# Skipping Backup #############################
./run_edge_solver.sh: 94: [[: not found
################################ File check ###############################
** File case_name.aboc NOT found !!!! **
** File case_name.ainp NOT found !!!! **
** File case_name.bedg NOT found !!!! **
** File case_name.bmsh NOT found !!!! **
############################ End of file check ############################
./run_edge_solver.sh: 140: [[: not found
./run_edge_solver.sh: 140: [[: not found
Parallel computation with 1 processors
file case_name.ainp is not readable
Wygląda na to, jakbym miał jakiś problem z interpreterem BASH. Nawet przeinstalowałem pakiety:
Kod: Zaznacz cały
bash
bash-completion
gnome-terminal
gnome-terminal-data
Kod: Zaznacz cały
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
HISTCONTROL=$HISTCONTROL${HISTCONTROL+:}ignoredups
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
#alias grep='grep --color=auto'
#alias fgrep='fgrep --color=auto'
#alias egrep='egrep --color=auto'
fi
# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
# Edge Solver 5.2.0
PATH=$PATH:/home/krzych/Programy/edge-solver-5.2.0/bin
#LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/krzych/Programy/edge-solver-5.2.0/lib/lapack-3.3.1/lib
# OpenFOAM
#. /opt/openfoam171/etc/bashrc
Specyfikacja systemowa:
uname -a
Kod: Zaznacz cały
Linux debian 2.6.38-2-amd64 #1 SMP Sun May 8 13:51:57 UTC 2011 x86_64 GNU/Linux
source.list
Kod: Zaznacz cały
#
#~~~~~~Wheezy~~~~~~#
deb http://ftp.pl.debian.org/debian/ testing main non-free contrib
deb-src http://ftp.pl.debian.org/debian/ testing main non-free contrib
deb http://security.debian.org/ testing/updates main contrib non-free
deb-src http://security.debian.org/ testing/updates main contrib non-free
#~~~~~~Opera~~~~~~#
deb http://deb.opera.com/opera/ testing non-free
#~~~~~~Debian-multimedia~~~~~~#
deb http://www.debian-multimedia.org testing main non-free
deb-src http://www.debian-multimedia.org testing main non-free
#~~~~~~OpenFoam~~~~~~#
deb http://www.openfoam.com/download/ubuntu lucid main
deb http://ppa.launchpad.net/nikount/orta-desktop/ubuntu lucid main
deb-src http://ppa.launchpad.net/nikount/orta-desktop/ubuntu lucid main
Bardzo proszę o pomoc, nie mam zielonego pojęcia co się u mnie namieszało. Z góry dziękuję za wszelkie konstruktywne uwagi.
Pozdrawiam
Alth