29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#==============================================================================
# Can't always trust $PWD
CURRWD=$(pwd)
# Make sure nbfake host and logfile are set. Fall back to old-style variable names
if [[ -z "$NBFAKE_HOST" && -n "$TARGETHOST" ]]; then NBFAKE_HOST=$TARGETHOST; fi
if [[ -z "$NBFAKE_LOG" && -n "$TARGETHOST_LOGF" ]]; then NBFAKE_LOG=$TARGETHOST_LOGF; fi
# Set default nbfake log
if [[ -z "$NBFAKE_LOG" ]]; then
NBFAKE_LOG=NBFAKE-$(date +%GWW%V.%u_%T)
fi
#==============================================================================
# Run and log
#==============================================================================
cat <<__EOF >&2
#======================================================================
# NBFAKE logging command to: $NBFAKE_LOG
# $*
#======================================================================
__EOF
if [[ -z "$NBFAKE_HOST" ]]; then
# Run locally
sh -c "cd $CURRWD;export DISPLAY=$DISPLAY; export PATH=$PATH; nohup $* >> $NBFAKE_LOG 2>&1 &"
else
# run remotely
ssh -n -f $NBFAKE_HOST "sh -c \"cd $CURRWD;export DISPLAY=$DISPLAY; export PATH=$PATH; nohup $* >> $NBFAKE_LOG 2>&1 &\""
fi
|
|
>
>
>
>
>
>
|
>
>
>
>
>
|
|
|
|
|
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#==============================================================================
# Can't always trust $PWD
CURRWD=$(pwd)
# Make sure nbfake host and logfile are set. Fall back to old-style variable names
if [[ -z "$NBFAKE_HOST" && -n "$TARGETHOST" ]]; then
MY_NBFAKE_HOST=$TARGETHOST
else
MY_NBFAKE_HOST=$NBFAKE_HOST
unset NBFAKE_HOST
fi
if [[ -z "$NBFAKE_LOG" && -n "$TARGETHOST_LOGF" ]]; then
MY_NBFAKE_LOG=$TARGETHOST_LOGF
else
MY_NBFAKE_LOG=$NBFAKE_LOG
unset NBFAKE_LOG
fi
# Set default nbfake log
if [[ -z "$MY_NBFAKE_LOG" ]]; then
MY_NBFAKE_LOG=NBFAKE-$(date +%GWW%V.%u_%T)
fi
#==============================================================================
# Run and log
#==============================================================================
cat <<__EOF >&2
#======================================================================
# NBFAKE logging command to: $NBFAKE_LOG
# $*
#======================================================================
__EOF
if [[ -z "$MY_NBFAKE_HOST" ]]; then
# Run locally
sh -c "cd $CURRWD;export DISPLAY=$DISPLAY; export PATH=$PATH; nohup $* >> $MY_NBFAKE_LOG 2>&1 &"
else
# run remotely
ssh -n -f $MY_NBFAKE_HOST "sh -c \"cd $CURRWD;export DISPLAY=$DISPLAY; export PATH=$PATH; nohup $* >> $MY_NBFAKE_LOG 2>&1 &\""
fi
|