Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JCookie.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 # \author mdejong
4 #
5 script=${0##*/}
6 
7 if [ -z $JPP_DIR ]; then
8  echo "Variable JPP_DIR undefined."
9  exit
10 fi
11 
12 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
13 
14 set_variable COOKIE `getCookie`
15 set_variable TIMEOUT_S 20
16 
17 if do_usage $*; then
18  usage "$script"
19 fi
20 
21 # test cookie
22 
23 if [[ -f $COOKIE ]]; then
24 
25  JPrintDB -C $COOKIE -q detector >& /dev/null
26 
27  if (( $? != 0 )); then
28  echo "Remove broken cookie file $COOKIE";
29  rm -f $COOKIE
30  fi
31 fi
32 
33 if [[ ! -f $COOKIE ]]; then
34 
35  if [[ -z "$DBCOOKIE" ]]; then
36 
37  echo "Enter input within $TIMEOUT_S seconds."
38  echo -n "User name: "
39  read -t $TIMEOUT_S USR
40  if (( $? != 0 )); then
41  fatal "Timeout at user input."
42  fi
43  echo -n "Password: "
44  read -t $TIMEOUT_S -s PWD
45  echo
46  if (( $? != 0 )); then
47  fatal "Timeout at user input."
48  fi
49 
50  set_variable SERVER `JServerDB`
51 
52  wget --no-check-certificate \
53  "https://${SERVER}/home.htm?usr=${USR}&pwd=${PWD}&persist=y" \
54  -O $COOKIE && sed -i -- "s/sid=/.in2p3.fr\\tTRUE\\t\/\\tTRUE\\t0\\tsid\\t/g" $COOKIE
55 
56  if [[ ! -f $COOKIE ]]; then
57  fatal "No cookie $COOKIE"
58  fi
59  else
60 
61  echo "Using DBCOOKIE; unset to disable."
62  fi
63 fi
64 
65 JPrintDB -C $COOKIE -q detector >& /dev/null
66 
67 CHECK_EXIT_CODE
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null if do_usage *then usage $script fi SERVER
bool read(Vec &v, std::istream &is)
Read a Vec(tor) from a stream.
Definition: io_ascii.hh:141
exit
Definition: JPizza.sh:36
then JPizza f
Definition: JPizza.sh:46
then echo
static const double C
Physics constants.
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable
Definition: JAcoustics.sh:20
* usage
then echo Remove broken cookie file $COOKIE
Definition: JCookie.sh:28
alias put_queue eval echo n
Definition: qlib.csh:19
esac timer_start JCookie sh set_variable COOKIE(cat~/.km3netdb_cookie) set_variable LOGIN $
Definition: JEditTuneHV.sh:81
do set_variable DETECTOR_TXT $WORKDIR detector
script
Definition: JAcoustics.sh:2
esac $JPP_BIN JLogger sh $LOGGER until pgrep JGetMessage</dev/null > dev null