Fortran Error:Bad continuation line at (1) - unix
I am trying to use fortran to write a Unix script into a file. Nonetheless, it keeps reminding me that my format is incorrect. I have been doing this for many times and they are all succeed to be compiled. For this time, I do not know what goes wrong. I have attached my codes and the information on errors and I will be very grateful if someone can point out my mistakes. Thanks!!!
subroutine get_gmt(max1,min1,max2,min2,max3,min3,max4,min4)
real*4 max1,min1,max2,min2,max3,min3,max4,min4
real*4 dt1,dt2,dt3,dt4
real*4 dtt1,dtt2,dtt3,dtt4
dt1 = (max1-min1)/2000
dt2 = (max1-min1)/8
open(23,file='plot.gmt')
write(23,100) dt1,dt2,min1,max1,min2
& ,max2,min3,max3,min4,max4
100 format('#!/bin/bash', /
& 'rm tmp?.ps tmp?.cpt',//
& 'set dt1= ',f11.5,/
& 'set dt2= ',f11.5,/
& 'set T1= ',f11.5,/
& 'set T2= ',f11.5,/
& 'set T3= ',f11.5,/
& 'set T4= ',f11.5,/
& 'set T5= ',f11.5,/
& 'set T6= ',f11.5,/
& 'set T7= ',f11.5,/
& 'set T8= ',f11.5,/
& 'psbasemap -R0/360/0/90 -JPa3/0
& -P -Ba40/a10 -V -X6.5 -Y24 -K > tmp.ps',/
& 'surface data.dat -Gtmp.grd -I0.05/0.05
& -R -C100 -T0.35 -N10 -V',//
& 'makecpt -Crainbow -T$T1/$T2/$dt1 -Z -V > tmp.cpt',/
& 'makecpt -Crainbow -T$T1/$T2/$dt2 -Z -V > tmp1.cpt',//
& 'psscale -D-1.25/1.5/3/0.4 -Ctmp1.cpt -L -O -K -A >> tmp.ps',//
& 'grdimage tmp.grd -R -JP -O -Ctmp.cpt -V -K >> tmp.ps',//
& 'gawk ''{print $2,$5,0.5*$3}'' result4.dat | psxy
& -R -JP -K -O -B -V -Sc -N -W0.5,red >> tmp.ps',//
& 'psxyz -R0/2/0/2/0/2 -JX2/2 -JZ2 -E135/30 -Sc0.1
& -W4,red -P -Gred -Bx1 -By1 -Bz1 -BWSneZ
& -N -X-6.0 -K -O <<END>> tmp.ps',/
& '0 0 1',/
& '0 0 0',/
& 'END',//
& 'pstext -R -JX -O -K -JZ -E -W4,red -P -B -N <<END>> tmp.ps',/
& '-0.2 0 0 9 0 15 subevent1',/
& '0 0 1.2 9 0 15 subevent2',/
& 'END',//
& 'gawk ''{print $1,$2}'' time.dat |psxy -R0/360/$T1/$T2 -JX3/3 -P -Ba60/a$dt2
& -V -K -O -Sc0.05 -N -X10.5 -P >> tmp.ps',//
& 'gawk ''{print $2,$5}'' result4.dat |psxy -R
& -JX -K -O -B -V -Sa0.15 -N -W0.5,red
& >> tmp.ps',//
& 'gmtset BASEMAP_AXES = WeSN',/
& 'gmtset FONT_ANNOT_PRIMARY 7p',//
& 'gawk ''{print $1,$2}'' time1.dat |psxy
& -R0/90/$T1/$T2 -JX3/3 -P -Ba15/a$dt2 -V -K -O
& -Sc0.05 -N -X4.5 >> tmp.ps',//
& 'psbasemap -R0/360/0/90 -JPa3/0 -P
& -Ba40/a10 -V -X-9 -Y-5 -K -O >> tmp.ps',/
& 'surface data1.dat -Gtmp1.grd -I0.1/0.1 -R -C100 -T0 -N10 -V',//
& 'makecpt -Crainbow -T$T3/$T4/$dt1 -Z -V > tmp3.cpt',//
& 'makecpt -Crainbow -T$T3/$T4/$dt2 -Z -V > tmp4.cpt',//
& 'psscale -D-1.25/1.5/3/0.4
& -Ctmp4.cpt -L -O -K -A >> tmp.ps',//
& 'grdimage tmp1.grd -R -JP -O -Ctmp3.cpt -V -K >> tmp.ps',//
& 'gawk ''{print $2,$5,0.5*$3}'' result4.dat |
& psxy -R -JP -K -O -B -V
& -Sc -N -W0.5,red >> tmp.ps',//
& 'psxyz -R0/2/0/2/0/2 -JX2/2 -JZ2 -E135/30
& -Sc0.1 -W4,red -P -Gred -BWSneZ -Bx1 -By1
& -Bz1 -N -X-6.0 -K -O <<END>> tmp.ps',/
& '1 0 0',/
& '0 0 0',/
& 'END',//
& 'gmtset BASEMAP_AXES = WeSN',/
& 'gmtset FONT_ANNOT_PRIMARY 7p',//
& 'gawk ''{print $1,$2}'' time4.dat |psxy
& -R0/360/$T3/$T4 -JX3/3 -P -Ba60/a$dt2 -V -K -P
& -Sc0.05 -N -X10.5 >> tmp.ps',//
& ‘gmtset BASEMAP_AXES = WeSN',/
& 'gmtset FONT_ANNOT_PRIMARY 7p',//
& 'gawk ''{print $1,$2}'' time3.dat |psxy
& -R0/90/$T3/$T4 -JX3/3 -P -K -Ba15/a$dt2 -V
& -X4.5 -O -Sc0.05 -N >> tmp.ps',//
& 'psbasemap -R0/360/0/90 -JPa3/0 -P
& -Ba40/a10 -V -X6.5 -Y24 -K > tmp1.ps',/
& 'surface data2.dat -Gtmp2.grd
& -I0.1/0.1 -R -C100 -T0 -N10 -V',//
& 'makecpt -Crainbow -T$T5/$T6/$dt1 -Z -V > tmp5.cpt',/
& 'makecpt -Crainbow -T$T5/$T6/$dt2 -Z -V > tmp6.cpt',//
& 'psscale -D-1.25/1.5/3/0.4
& -Ctmp6.cpt -V -K -O -A -L >> tmp1.ps',//
& 'grdimage tmp2.grd -R -JP -O
& -Ctmp5.cpt -V -K >> tmp1.ps',//
& 'gawk ''{print $2,$5,0.5*$3}'' result4.dat |psxy -R
& -JP -K -O -B -V -Sc -N -W0.5,red
& >> tmp1.ps',/
& 'psxyz -R0/2/0/2/0/2 -JX2/2 -JZ2 -E135/30
& -Sc0.1 -W4,red -P -Gred -Bx1 -By1 -Bz1
& -BWSneZ -N -X-6.0 -K -O <<END>>tmp1.ps',/
& '0 1 0',/
& '0 0 0',/
& 'END',//
& 'gmtset BASEMAP_AXES = WeSN',/
& 'gmtset FONT_ANNOT_PRIMARY 7p',//
& 'gawk ''{print $1,$2}'' time6.dat |psxy -R0/360/$T5/$T6
& -JX3/3 -P -Ba60/a$dt2 -V
& -X10.5 -K -O -Sc0.05 -N >> tmp1.ps',//
& 'gmtset FONT_ANNOT_PRIMARY 7p',//
& 'gawk ''{print $1,$2}'' time5.dat |psxy -R0/90/$T5/$T6
& -JX3/3 -P -Ba15/a$dt2 -V
& -X4.5 -O -Sc0.05 -N -K >> tmp1.ps',//
& 'psbasemap -R0/360/0/90 -JPa3/0 -P
& -Ba40/a10 -V -X-9 -Y-5 -K -O >> tmp1.ps',/
& 'surface data3.dat -Gtmp3.grd -I0.1/0.1 -R -C100 -T0 -N10 -V',//
& 'makecpt -Crainbow -T$T7/$T8/$dt1 -Z -V > tmp9.cpt',//
& 'makecpt -Crainbow -T$T7/$T8/$dt2 -Z -V > tmp10.cpt',//
& 'psscale -D-1.25/1.5/3/0.4
& -Ctmp10.cpt -L -O -K -A >> tmp2.ps',//
& 'gawk ''{print $2,$5,$3}'' result4.dat |psxy
& -R -JP -K -O -B -V -Sc0.1 -Ctmp9.cpt -N
& -Gblack >> tmp2.ps',//
& 'BASEMAP_AXES = WeSN',/
& 'FONT_ANNOT_PRIMARY 7p',//
& 'gawk ''{print $2,$3}'' result4.dat |psxy
& -R0/360/$T7/$T8 -JX3/3 -P -Ba60/a$dt2 -V
& -X4.5 -K -O -Sc0.05 -N >> tmp2.ps',//
& 'gmtset BASEMAP_AXES = WeSN',/
& 'gmtset FONT_ANNOT_PRIMARY 7p',//
& 'gawk ''{print $5,$3}'' result4.dat |psxy -R0/90/$T7/$T8
& -JX3/3 -P -Ba15/a$dt2 -V
& -X4.5 -O -Sc0.05 -N >> tmp2.ps')
close(23)
end
And it reports numerous errors, but the typical errors are as follows:
& 'grdimage tmp.grd -R -JP -O -Ctmp.cpt -V -K >> tmp.ps',//
Error: Positive width required in format specifier G at (1)
forward_modeling.f:407:6:
& 'gmtset FONT_ANNOT_PRIMARY 7p',//
1
Error: Bad continuation line at (1)
forward_modeling.f:407:15:
& 'gmtset FONT_ANNOT_PRIMARY 7p',//
1
Error: Invalid character in name at (1)
forward_modeling.f:410:6:
& -JX3/3 -P -Ba15/a$dt2 -V
1
Error: Bad continuation line at (1)
Error: Unclassifiable statement at (1)
forward_modeling.f:285:72:
& ,max2,min3,max3,min4,max4
1
Error: FORMAT label 100 at (1) not defined
Related
How to execute unix command after few background jobs are completed?
My c-shell code has to complete few concurrent background jobs before execution of some unix commands. However, somehow in code my background jobs never returns handle to unix commands. i.e. $cmd1 | tee $XD/m1.log& $cmd2 | tee $XD/m2.log& $cmd3 | tee $XD/m3.log& $cmd4 | tee $XD/m4.log& All 4 commands mentioned above generate 4 different files named $L1,$L2,$L3 and $L4 (example: setenv L1 $XD/div.txt etc.). I need to merge all of these files after removing the first line from them so have used following logic. But seems like sed command never gets executed wait $! echo "Job completed" sed -i '1d' $L2 sed -i '1d' $L3 sed -i '1d' $L4 cat $L1 $L2 $L3 $L4 >> $L Could you please help me to make then executes post background jobs? tried if (! -e $L4 ) then if ( -f $L4 ) then wait $! echo "Job completed" sed -i '1d' $L2 sed -i '1d' $L3 sed -i '1d' $L4 cat $L1 $L2 $L3 $L4 >> $L endif endif but didn't help either. $cmd1 | tee $XD/m1.log& $cmd2 | tee $XD/m2.log& $cmd3 | tee $XD/m3.log& $cmd4 | tee $XD/m4.log& if (! -e $L4 ) then if ( -f $L4 ) then wait $! echo "Job completed" sed -i '1d' $L2 sed -i '1d' $L3 sed -i '1d' $L4 cat $L1 $L2 $L3 $L4 >> $L endif endif Expected results would be to generate $L file ($XD/final.txt), which would happen only when script will be back to 2nd half section containing sed command.
Short answer, just use: wait wait without any parameter wait will wait for all children processes. $! is pid of the last background process started so wait $! will wait only for process last child process. Long answer, full script edited: #!/bin/env tcsh set cmd1 = 'printf header\nline11\nline12\n' set cmd2 = 'printf header\nline21\nline22\n' set cmd3 = 'printf header\nline31\nline32\n' set cmd4 = 'printf header\nline41\nline42\n' set XD = '.' set L = "${XD}/m.log" set L1 = "${XD}/m1.log" set L2 = "${XD}/m2.log" set L3 = "${XD}/m3.log" set L4 = "${XD}/m4.log" touch "${L}" "${L1}" "${L2}" "${L3}" "${L4}" || exit (1) ( ${cmd1}; sleep 5 ) | tee "${L1}" & ( ${cmd2}; sleep 2 ) | tee "${L2}" & ( ${cmd3}; sleep 4 ) | tee "${L3}" & ( ${cmd4}; sleep 3 ) | tee "${L4}" & wait echo "Job completed" cat "${L1}" > "${L}" sed '1d' "${L2}" >> "${L}" sed '1d' "${L3}" >> "${L}" sed '1d' "${L4}" >> "${L}" exit (0) Test: % ./user3093942.tcsh [1] 1542 1543 header line11 line12 [2] 1545 1546 header line21 line22 [3] 1548 1549 header line31 line32 [4] 1551 1552 header line41 line42 [4] + Done ( ${cmd4}; sleep 3 ) | tee ./m4.log [3] + Done ( ${cmd3}; sleep 4 ) | tee ./m3.log [2] + Done ( ${cmd2}; sleep 2 ) | tee ./m2.log [1] + Done ( ${cmd1}; sleep 5 ) | tee ./m1.log Job completed % cat ./m.log header line11 line12 line21 line22 line31 line32 line41 line42
Unix shell - syntax error near unexpected token `done'
Below is my code. #!/bin/ksh curdate=$(date '+%d%h,%Y') while read line; do echo "$line" > new10.txt str0=$(cut -f 2 new10.txt) str01=$(cut -f 1 -d ',' new10.txt) str1=$(cut -f 2 -d ',' new10.txt) str2=$(cut -c 3 $str1) if [ $str2=':' ]; then str2=',2016' finalstr=$str01$str2 if [ '01jan2017' -le $finalstr -le $curdate ]; then finalstr1=$str01',2017' else finalstr1=$str01',2016' echo $finalstr1 > datefinal.txt fi done < /export/home/islams/PISAS/userwiseutil/date.txt I am getting following errors: date1.sh: line 22: syntax error near unexpected token done' date1.sh: line 22:done < /export/home/islams/PISAS/userwiseutil/date.txt'
#!/bin/ksh curdate=$(date '+%d%h,%Y') while read line; do echo "$line" > new10.txt str0=$(cut -f 2 new10.txt) str01=$(cut -f 1 -d ',' new10.txt) str1=$(cut -f 2 -d ',' new10.txt) str2=$(cut -c 3 $str1) if [ $str2=':' ]; then str2=',2016' finalstr=$str01$str2 if [ '01jan2017' -le $finalstr -le $curdate ]; then finalstr1=$str01',2017' else finalstr1=$str01',2016' echo $finalstr1 > datefinal.txt fi fi #You missed this done < /export/home/islams/PISAS/userwiseutil/date.txt You missed one fi
puma recipe failing on CentOS
I'm trying create a chef-solo recipe for using puma on centos6. All of the guides that I see are targeted towards Ubuntu using Upstart. I've tried making modifications to use init but it still fails with the error * /etc/init.d/puma-manager does not exist!. /recipes/puma.rb # add puma init conf template '/etc/init/puma.conf' do source 'puma-init.conf.erb' mode 0644 end # add puma manager conf template '/etc/init/puma-manager.conf' do source 'puma-manager.conf.erb' mode 0644 end # add puma conf template '/etc/puma.conf' do source 'puma.conf.erb' mode 0644 end cookbook_file '/etc/init.d/puma' do source 'puma' owner 'deploy' group 'deploy' mode '0755' action :create end cookbook_file '/usr/local/bin/run-puma' do source 'run-puma' owner 'deploy' group 'deploy' mode '0755' action :create end # add puma app conf template "#{node['app_shared_path']}/config/puma.rb" do source 'puma.rb.erb' mode 0644 # notifies :restart, 'service[puma]', :delayed end service 'puma-manager' do provider Chef::Provider::Service::Init supports ['start', 'stop', 'restart', 'status'] action :start end /files/default/puma #! /bin/sh ### BEGIN INIT INFO # Provides: puma # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Example initscript # Description: This file should be used to construct scripts to be # placed in /etc/init.d. ### END INIT INFO # Author: Darío Javier Cravero <dario#exordo.com> # # Do NOT "set -e" # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/usr/local/bin:/usr/local/sbin/:/sbin:/usr/sbin:/bin:/usr/bin DESC="Puma rack web server" NAME=puma DAEMON=$NAME SCRIPTNAME=/etc/init.d/$NAME CONFIG=/etc/puma.conf JUNGLE=`cat $CONFIG` RUNPUMA=/usr/local/bin/run-puma USE_LOCAL_BUNDLE=0 # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # # Function that starts the jungle # do_start() { log_daemon_msg "=> Running the jungle..." for i in $JUNGLE; do dir=`echo $i | cut -d , -f 1` user=`echo $i | cut -d , -f 2` config_file=`echo $i | cut -d , -f 3` if [ "$config_file" = "" ]; then config_file="$dir/config/puma.rb" fi log_file=`echo $i | cut -d , -f 4` if [ "$log_file" = "" ]; then log_file="$dir/log/puma.log" fi environment=`echo $i | cut -d , -f 5` do_start_one $dir $user $config_file $log_file $environment done } do_start_one() { PIDFILE=$1/tmp/puma/pid if [ -e $PIDFILE ]; then PID=`cat $PIDFILE` # If the puma isn't running, run it, otherwise restart it. if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then do_start_one_do $1 $2 $3 $4 $5 else do_restart_one $1 fi else do_start_one_do $1 $2 $3 $4 $5 fi } do_start_one_do() { log_daemon_msg "--> Woke up puma $1" log_daemon_msg "user $2" log_daemon_msg "log to $4" if [ ! -z "$5" ]; then for e in $(echo "$5" | tr ';' '\n'); do log_daemon_msg "environment $e" v=${e%%\=*} ; eval "$e" ; export $v done fi start-stop-daemon --verbose --start --chdir $1 --chuid $2 --background --exec $RUNPUMA -- $1 $3 $4 } # # Function that stops the jungle # do_stop() { log_daemon_msg "=> Putting all the beasts to bed..." for i in $JUNGLE; do dir=`echo $i | cut -d , -f 1` do_stop_one $dir done } # # Function that stops the daemon/service # do_stop_one() { log_daemon_msg "--> Stopping $1" PIDFILE=$1/tmp/puma/pid STATEFILE=$1/tmp/puma/state if [ -e $PIDFILE ]; then PID=`cat $PIDFILE` if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then log_daemon_msg "---> Puma $1 isn't running." else log_daemon_msg "---> About to kill PID `cat $PIDFILE`" if [ "$USE_LOCAL_BUNDLE" -eq 1 ]; then cd $1 && bundle exec pumactl --state $STATEFILE stop else pumactl --state $STATEFILE stop fi # Many daemons don't delete their pidfiles when they exit. rm -f $PIDFILE $STATEFILE fi else log_daemon_msg "---> No puma here..." fi return 0 } # # Function that restarts the jungle # do_restart() { for i in $JUNGLE; do dir=`echo $i | cut -d , -f 1` do_restart_one $dir done } # # Function that sends a SIGUSR2 to the daemon/service # do_restart_one() { PIDFILE=$1/tmp/puma/pid i=`grep $1 $CONFIG` dir=`echo $i | cut -d , -f 1` if [ -e $PIDFILE ]; then log_daemon_msg "--> About to restart puma $1" if [ "$USE_LOCAL_BUNDLE" -eq 1 ]; then cd $1 && bundle exec pumactl --state $dir/tmp/puma/state restart else pumactl --state $dir/tmp/puma/state restart fi # kill -s USR2 `cat $PIDFILE` # TODO Check if process exist else log_daemon_msg "--> Your puma was never playing... Let's get it out there first" user=`echo $i | cut -d , -f 2` config_file=`echo $i | cut -d , -f 3` if [ "$config_file" = "" ]; then config_file="$dir/config/puma.rb" fi log_file=`echo $i | cut -d , -f 4` if [ "$log_file" = "" ]; then log_file="$dir/log/puma.log" fi environment=`echo $i | cut -d , -f 5` do_start_one $dir $user $config_file $log_file $environment fi return 0 } # # Function that statuss the jungle # do_status() { for i in $JUNGLE; do dir=`echo $i | cut -d , -f 1` do_status_one $dir done } # # Function that sends a SIGUSR2 to the daemon/service # do_status_one() { PIDFILE=$1/tmp/puma/pid i=`grep $1 $CONFIG` dir=`echo $i | cut -d , -f 1` if [ -e $PIDFILE ]; then log_daemon_msg "--> About to status puma $1" if [ "$USE_LOCAL_BUNDLE" -eq 1 ]; then cd $1 && bundle exec pumactl --state $dir/tmp/puma/state stats else pumactl --state $dir/tmp/puma/state stats fi # kill -s USR2 `cat $PIDFILE` # TODO Check if process exist else log_daemon_msg "--> $1 isn't there :(..." fi return 0 } do_add() { str="" # App's directory if [ -d "$1" ]; then if [ "`grep -c "^$1" $CONFIG`" -eq 0 ]; then str=$1 else echo "The app is already being managed. Remove it if you want to update its config." exit 1 fi else echo "The directory $1 doesn't exist." exit 1 fi # User to run it as if [ "`grep -c "^$2:" /etc/passwd`" -eq 0 ]; then echo "The user $2 doesn't exist." exit 1 else str="$str,$2" fi # Config file if [ "$3" != "" ]; then if [ -e $3 ]; then str="$str,$3" else echo "The config file $3 doesn't exist." exit 1 fi fi # Log file if [ "$4" != "" ]; then str="$str,$4" fi # Environment variables if [ "$5" != "" ]; then str="$str,$5" fi # Add it to the jungle echo $str >> $CONFIG log_daemon_msg "Added a Puma to the jungle: $str. You still have to start it though." } do_remove() { if [ "`grep -c "^$1" $CONFIG`" -eq 0 ]; then echo "There's no app $1 to remove." else # Stop it first. do_stop_one $1 # Remove it from the config. sed -i "\\:^$1:d" $CONFIG log_daemon_msg "Removed a Puma from the jungle: $1." fi } config_bundler() { HOME="$(eval echo ~$(id -un))" if [ -d "/usr/local/rbenv/bin" ]; then PATH="/usr/local/rbenv/bin:/usr/local/rbenv/shims:$PATH" eval "$(rbenv init -)" USE_LOCAL_BUNDLE=1 return 0 elif [ -d "$HOME/.rbenv/bin" ]; then PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH" eval "$(rbenv init -)" USE_LOCAL_BUNDLE=1 return 0 # TODO: test rvm # elif [ -f /etc/profile.d/rvm.sh ]; then # source /etc/profile.d/rvm.sh # elif [ -f /usr/local/rvm/scripts/rvm ]; then # source /etc/profile.d/rvm.sh # elif [ -f "$HOME/.rvm/scripts/rvm" ]; then # source "$HOME/.rvm/scripts/rvm" # TODO: don't know what to do with chruby # elif [ -f /usr/local/share/chruby/chruby.sh ]; then # source /usr/local/share/chruby/chruby.sh # if [ -f /usr/local/share/chruby/auto.sh ]; then # source /usr/local/share/chruby/auto.sh # fi # if you aren't using auto, set your version here # chruby 2.0.0 fi return 1 } config_bundler case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" if [ "$#" -eq 1 ]; then do_start else i=`grep $2 $CONFIG` dir=`echo $i | cut -d , -f 1` user=`echo $i | cut -d , -f 2` config_file=`echo $i | cut -d , -f 3` if [ "$config_file" = "" ]; then config_file="$dir/config/puma.rb" fi log_file=`echo $i | cut -d , -f 4` if [ "$log_file" = "" ]; then log_file="$dir/log/puma.log" fi do_start_one $dir $user $config_file $log_file fi case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" if [ "$#" -eq 1 ]; then do_stop else i=`grep $2 $CONFIG` dir=`echo $i | cut -d , -f 1` do_stop_one $dir fi case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; status) # TODO Implement. log_daemon_msg "Status $DESC" "$NAME" if [ "$#" -eq 1 ]; then do_status else i=`grep $2 $CONFIG` dir=`echo $i | cut -d , -f 1` do_status_one $dir fi case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; restart) log_daemon_msg "Restarting $DESC" "$NAME" if [ "$#" -eq 1 ]; then do_restart else i=`grep $2 $CONFIG` dir=`echo $i | cut -d , -f 1` do_restart_one $dir fi case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; add) if [ "$#" -lt 3 ]; then echo "Please, specifiy the app's directory and the user that will run it at least." echo " Usage: $SCRIPTNAME add /path/to/app user /path/to/app/config/puma.rb /path/to/app/config/log/puma.log" echo " config and log are optionals." exit 1 else do_add $2 $3 $4 $5 fi case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; remove) if [ "$#" -lt 2 ]; then echo "Please, specifiy the app's directory to remove." exit 1 else do_remove $2 fi case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; *) echo "Usage:" >&2 echo " Run the jungle: $SCRIPTNAME {start|stop|status|restart}" >&2 echo " Add a Puma: $SCRIPTNAME add /path/to/app user /path/to/app/config/puma.rb /path/to/app/config/log/puma.log" echo " config and log are optionals." echo " Remove a Puma: $SCRIPTNAME remove /path/to/app" echo " On a Puma: $SCRIPTNAME {start|stop|status|restart} PUMA-NAME" >&2 exit 3 ;; esac : /files/default/run-puma #!/bin/bash app=$1; config=$2; log=$3; cd $app && exec bundle exec puma -C $config 2>&1 >> $log
First of all, your service name seems to be wrong. It seems like it should be called service 'puma' instead of puma-manager. Besides that, a init script from Debian/Ubuntu will not work on CentOS without modifications. Some required files like the helper methods from the init-functions do not exist on CentOS. Depending on the script, those modification can be quite complex and sometimes it's better to write a new script from scratch. Anyway, there is a non-official CentOS init script example for Puma here: https://github.com/puma/puma/issues/178 But it is a little old/untested and I'm not sure it will work without modification.
R - system commands with multiple pipe do not return stdout
bash: ps -aux | grep -E "^.*\b[^grep](python).*(runserver).*$" 2>/dev/null | tr -s " " | cut -d " " -f 2 It's return correct result. (eg.) 1450 1452 This same code in R vLog <- system('ps -aux | grep -E "^.*\b[^grep](python).*(runserver).*$" 2>/dev/null | tr -s " " | cut -d " " -f 2', intern = TRUE) return character(0)
Just replace \b with \\b and also be aware of [^grep] which matches any character but not of g or r or e or p. vLog <- system('ps -aux | grep -E "^.*\\b[^grep](python).*(runserver).*$" 2>/dev/null | tr -s " " | cut -d " " -f 2', intern = TRUE) Example: > system('ps -aux | grep -E "^.*\\bpython" 2>/dev/null | tr -s " " | cut -d " " -f 2', intern = TRUE) [1] "2519" "2526" "3285" "3291" > system('ps -aux | grep -E "^.*\bpython" 2>/dev/null | tr -s " " | cut -d " " -f 2', intern = TRUE) character(0)
start-stop-daemon and javaFX program
this is driving me crazy, please could you help with the start-stop-daemon to start a javafx jar file, where I need to issue the following command to start it sudo /opt/jdk1.8.0/bin/java -Djavafx.platform=eglfb -cp /opt/jdk1.8.0/jre/lib/jfxrt.jar:/home/pi/prayertime/JavaFXApplication4.jar javafxapplication4.JavaFXApplication4 & and the start_stop_daemon script is as follows #!/bin/sh # # init script for ship-it # ### BEGIN INIT INFO # Provides: ship-it # Required-Start: $remote_fs $syslog $network # Required-Stop: $remote_fs $syslog $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: init script for the ship-it box # Description: We'll have to fill this out later... ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin NAME=prayertime DAEMON=/home/pi/prayertime/JavaFXApplication4.jar DAEMONARGS="javafxapplication4.JavaFXApplication4" PIDFILE=/var/run/$NAME.pid LOGFILE=/var/log/$NAME.log . /lib/lsb/init-functions test -f $DAEMON || exit 0 case "$1" in start) start-stop-daemon --start --background \ --pidfile $PIDFILE --make-pidfile --startas /bin/bash \ -- -c "exec sudo /opt/jdk1.8.0/bin/java -Djavafx.platform=eglfb -cp /opt/jdk1.8.0/jre/lib/jfxrt.jar: $DAEMON $DAEMONARGS > $LOGFILE 2>&1" log_end_msg $? ;;