LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 08-08-2006, 05:03 PM   #1
lpn1160
Member
 
Registered: May 2004
Location: USA
Distribution: pclinuxos
Posts: 37

Rep: Reputation: 15
at -f and shell script


Thanks to all in advance for any help and advice.
I capture videos using this script:

if [ -z "$1" ]; then
echo "Usage: time outputfilenames"
exit 1
fi
mkdir `date +%Y-%d-%m-%H:%M` && cd `date +%Y-%d-%m-%H:%M`

streamer -n ntsc -b 24 -t $1 -s 480x480 -r 29.970 -R 48000 -o stream0.avi -f mjpeg -j 95 -F stereo && mencoder -idx stream0.avi -ovc copy -oac copy -o $2 && rm stream0.avi
clear
exit 0
I tried useing the at command with this script and it did not work. error messages were "garbled time" or "broken token" In this script $1= length of capture and $2 is final file name. I have in the past captured with the at command but everything had to be setup first, I could not add length or file name on the fly. Is there a way to use this with the at command?

thanks in advance
PClinuxOS V.93
AthlonXP 2400
1GB DDR 2100
 
Old 08-08-2006, 06:05 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
I tried useing the at command with this script and it did not work. error messages were "garbled time" or "broken token"
The script will work. Error messages like "garbled time" just means you didn't tell "at" the right time format to run the script like:
at -f scriptname now
at -f scriptname now + 10 min
at -f scriptname 23:01
at -f scriptname tomorrow
at -f scriptname 23:01 10.08.2006
 
Old 08-08-2006, 08:34 PM   #3
lpn1160
Member
 
Registered: May 2004
Location: USA
Distribution: pclinuxos
Posts: 37

Original Poster
Rep: Reputation: 15
I guess I didn't make myself clear, yes I know all those commands and They work fine, but what about a script that needs input parameters. This doesn't work

./ at -f film_cap 20:00 1:45:00 the_sixth_sense

1:45:00 being the length of time I want to capture,the_sixth_sense=being the file name of the output.
 
Old 08-09-2006, 08:38 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
what about a script that needs input parameters.
Next time if you ask something phrase it like a question. Here's how:
Code:
#!/bin/sh
# Queue capture job using At
progn="capq"; capdir=~/caps; args=("$@"); argn=${#args[@]}
__help() { echo "${progn}: capturename duration at-timespec"; exit 1; }
__chkTime() { echo "${args[$1]}"|grep -q"[0-9]\{2\}:[0-9]\{2\}" || { echo "${progn} [FATAL]: wrong time format." && exit 127; }; }

# Check args
if [ "$argn" -lt "3" -o "$argn" -gt "5" ]; then echo "${progn} [FATAL]: not enough args."; __help; fi

# Check duration timespec
 __chkTime 1

# At time and date
cap="${args[0]}"; len="${args[1]}"; unset args[0] args[1]
args=(${args[@]}); case "${#args[@]}" in
1) __chkTime 0; time="${args[0]}";;
2) __chkTime 0; time="${args[0]}"; date="${args[1]}";;
0|*) __help;; esac

# Start job one minute in advance (for setup, load, app startup, whatever)
time_h="${time:0:2}"; time_m="${time:3:2}"
case "$time_m" in 00) time_m="59"
case "$time_h" in 00) time_h="23";; *) time_h=$[${time:0:2}-1];; esac;;
*)  time_m=$[${time:3:2}-1];; esac
if [ ${#time_m} = "1" ]; then time_m="0${time_m}"; fi
if [ ${#time_h} = "1" ]; then time_h="0${time_h}"; fi
starttime="${time_h}:${time_m}"

# Use tempfile for dumping at job
t="/tmp/${progn}.at.$$"; if [ -f "$t" ]; then rm -f "$t"; fi
cat <<EOC > "$t"
TMPDIR=\$(mktemp -td ${progn}.XXXXXXXXXX) && {
 streamer -n ntsc -b 24 -t ${time} -s 480x480 -r 29.970 -R 48000 \
 -o "\${TMPDIR}/stream0.avi" -f mjpeg -j 95 -F stereo &&\
 mencoder -idx "\${TMPDIR}/stream0.avi" -ovc copy -oac copy -o "${capdir}/${cap}.avi"
 cd; rm -rf "\${TMPDIR}"
}
EOC
#...and clean up
at -f "$t" "$starttime" "$date"; rm -f "$t"

exit 0
This script accepts "capturename duration at-timespec" params, where at-timespec can be queued as HH:MM or HH:MM DD.MM.YYYY. YMMV(VM).
 
  


Reply



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
Shell script inside shell script treotan Linux - General 4 02-19-2009 06:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
I made a shortcut to a shell script and it is using default shell icon... shlinux Linux - Software 2 04-20-2006 06:29 AM
Alias or shell script to confirm 'exit' commands from a shell rose_bud4201 Programming 2 03-08-2006 02:34 PM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM

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

All times are GMT -5. The time now is 03:47 AM.

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