renkinjutsu
March 15th, 2009, 09:44 AM
having some trouble with scripting
Below is just a test i'm running, and trying to get to work correctly.
#!/bin/bash
echo "Please enter working directory: "
read wdir
if [ ! -f "$wdir"/cvprefs ] ; then
echo "input filetype is: "
read ext ; echo "ext=\"$ext\"" >> "$wdir/cvprefs"
echo "output filetype is: "
read extout ; echo "extout=\"$extout\"" >> "$wdir/cvprefs"
echo "Video encode bitrate desired: "
read vbit ; echo "vbit=\"$vbit\"" >> "$wdir/cvprefs"
echo "filename: front portion"
read ff ; echo "ff=\"$ff\"" >> "$wdir/cvprefs"
echo "Series? y/n"
read ser ; echo "ser=\"$ser\"" >> "$wdir/cvprefs"
else
echo "Continuing from incomplete job"
wait 5
sh "$wdir/cvprefs"
fi
echo $ext
echo $extout
echo $vbit
echo $ff
echo $ser
echo
echo Correct?
i'm trying to write a script that queues video conversion using the handbrakecli .. i got the queue to work fine, and the script prompts the user for settings .. then i realized that it'd be bothersome having to keep inputting the settings for a specific batch/job (if you stopped the job in the middle without finishing it) everytime you open up the script again
so my solution was to save the preferences for that specific job into the working directory.. but the problem is, when i sh into that text file(cvprefs), the variables don't stick! I get a bunch of blank lines outputted from the echo commands. I believe it's because sh runs as a separate process... right?
also i tried to use `cat cvprefs` with the backward ticks instead of using sh, but that gives me
bash: ext="avi": command not found
i'm not very experienced, so this is driving me nuts! i can't find a solution!
Below is just a test i'm running, and trying to get to work correctly.
#!/bin/bash
echo "Please enter working directory: "
read wdir
if [ ! -f "$wdir"/cvprefs ] ; then
echo "input filetype is: "
read ext ; echo "ext=\"$ext\"" >> "$wdir/cvprefs"
echo "output filetype is: "
read extout ; echo "extout=\"$extout\"" >> "$wdir/cvprefs"
echo "Video encode bitrate desired: "
read vbit ; echo "vbit=\"$vbit\"" >> "$wdir/cvprefs"
echo "filename: front portion"
read ff ; echo "ff=\"$ff\"" >> "$wdir/cvprefs"
echo "Series? y/n"
read ser ; echo "ser=\"$ser\"" >> "$wdir/cvprefs"
else
echo "Continuing from incomplete job"
wait 5
sh "$wdir/cvprefs"
fi
echo $ext
echo $extout
echo $vbit
echo $ff
echo $ser
echo
echo Correct?
i'm trying to write a script that queues video conversion using the handbrakecli .. i got the queue to work fine, and the script prompts the user for settings .. then i realized that it'd be bothersome having to keep inputting the settings for a specific batch/job (if you stopped the job in the middle without finishing it) everytime you open up the script again
so my solution was to save the preferences for that specific job into the working directory.. but the problem is, when i sh into that text file(cvprefs), the variables don't stick! I get a bunch of blank lines outputted from the echo commands. I believe it's because sh runs as a separate process... right?
also i tried to use `cat cvprefs` with the backward ticks instead of using sh, but that gives me
bash: ext="avi": command not found
i'm not very experienced, so this is driving me nuts! i can't find a solution!