LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-04-2014, 04:12 AM   #1
tonj
Member
 
Registered: Sep 2008
Posts: 546

Rep: Reputation: 37
running startup script hangs in console


I have a program that I start in a console with the command /etc/init.d/stream start
It works fine but I don't get a return to the hash prompt in the console like I should. What I get in the console is:
Code:
[root@localhost ~]# /etc/init.d/stream start
Starting service…
Service started
[root@localhost ~]# Found AV/C device with GUID 0x002011011501d694
Waiting for DV...
Capture Started
if I press return again on the keyboard the hash prompt comes back but I need it to occur automatically.
this is the startup script (/etc/init.d/stream):
Code:
#!/bin/sh
### BEGIN INIT INFO
# Provides:          stream
# Required-Start:    $local_fs $network $named $time $syslog
# Required-Stop:     $local_fs $network $named $time $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Description:       start ffmpeg
### END INIT INFO

SCRIPT="dvgrab -format dv1 - | ffmpeg -deinterlace -f dv -i - -f flv \
-vcodec flv -s 640x360 -qscale 3.5 -acodec libmp3lame \
-ab 32k -ar 22050 'rtmp://172.16.1.250:1935/live/livestream1'"

RUNAS=root

PIDFILE=/var/run/stream.pid
LOGFILE=/var/log/stream.log
 
start() {
  if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then
    echo 'Service already running' >&2
    return 1
  fi
  echo 'Starting serviceā€¦' >&2
  local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
  su -c "$CMD" $RUNAS > "$PIDFILE"
  echo 'Service started' >&2
}
 
stop() {
  if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
    echo 'Service not running' >&2
    return 1
  fi
  echo 'Stopping serviceā€¦' >&2
  kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
  echo 'Service stopped' >&2
}
 
uninstall() {
  echo -n "Are you really sure you want to uninstall this service? That cannot be undone. [yes|No] "
  local SURE
  read SURE
  if [ "$SURE" = "yes" ]; then
    stop
    rm -f "$PIDFILE"
    echo "Notice: log file is not be removed: '$LOGFILE'" >&2
    update-rc.d -f stream remove
    rm -fv "$0"
  fi
}
 
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  uninstall)
    uninstall
    ;;
  retart)
    stop
    start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|uninstall}"
esac
I've tried both '&' and '$' on the command both in the console and in the script but it doesn't work.
what do I need to do to make this this script behave poperly in the console?
 
Old 07-04-2014, 04:19 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,486

Rep: Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556
You could try including the "functions" file from init.d and then seeing if using daemon to launch your app works.
 
Old 07-04-2014, 11:48 AM   #3
tonj
Member
 
Registered: Sep 2008
Posts: 546

Original Poster
Rep: Reputation: 37
thanks for your response but I don't really understand what you mean about including 'functions'. I do have a functions file in /etc/init.d. I've been googling all day on this but can't find anything that fits what you say.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to open a console and have a script running at startup rng Linux - General 2 01-11-2012 08:46 AM
X11 error: Can't open display - running a script from console pliqui Debian 3 10-08-2009 11:06 AM
"cd" doesn't take effect when running in script, but does in console ramow Programming 2 05-26-2007 03:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration