![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SH: two variables in for loop | marcpascual | Shell Programming and Scripting | 20 | 07-07-2009 07:23 AM |
| Is there a better way I could have run this loop. (For loop with two variables) | DeCoTwc | Shell Programming and Scripting | 2 | 03-27-2009 02:07 AM |
| foreach loop + 2 variables | JamesGoh | Shell Programming and Scripting | 3 | 06-04-2008 04:36 AM |
| While loop with Multiple variables | amit1_x | Shell Programming and Scripting | 4 | 04-02-2008 07:35 AM |
| using variables outside a while loop | Tornado | Shell Programming and Scripting | 2 | 02-09-2007 01:26 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Help with proper loop and variables
I have written a Bash Script that captures video via the Linux application DVgrab. When run my script prompts the terminal user to enter all the necessary information for the capture, save location, file name, file type capture duration etc... These are all in the form of Code:
#!/bin/bash echo -n "Enter the duration for the capture: " read duration dvgrab -loacation /home/somefolder -filetype avi -duration $duration This works great for me, my problem is that I want the script to run in such a way that once it finishes a capture it returns to the beginning of the script and asks for variables again to start another capture. My first attempt was simply to add Code:
#!/bin/bash time=5 until [ time = 1 ] do -my whole script- done And now you will see that I don't really know what I am doing or how to talk about it... I am just learning this stuff (I can only imagine there is a more correct 'repeat forever'?)My problem here is that once the script goes back to the 'do' line it already 'knows' all the variables and just starts the same dvgrab capture again... Is there a way to 'reset' all my entered variables? or perhaps some other method of looping that is more appropriate? Thanks -Starcast |
|
||||
|
Something like this, the loop stops if the user enters an empty string: Code:
#!/bin/bash
stop=1
while [ $stop -gt 0 ]
do
echo -n "Enter the duration for the capture: "
read duration
case "$duration" in
"") stop=0 ;;
*) dvgrab -loacation /home/somefolder -filetype avi -duration $duration ;;
esac
done
Regards |
|
||||
|
Hmm, I think I wasn't clear in what I'm trying to achieve. My problem is not related to stopping the script, but in getting the script to repeat.
There are 4 questions that the script prompts the user to enter as variables, and what I want to script to do is essentially start over once it's finished. So that after one tape ends, the script is already waiting for the information (a new instance of each of the variables) for the next tape to be entered... As it stands I achieve this by simply typing in the command to run the script again after each tape finishes, but I want to eliminate this extra step. Thanks for your help -Starcast |
|
||||
|
Read error: Resource Unavailable
Franklin52: Your Loop suggestion works perfectly for what I want, thanks... But I've discovered my problem is not in my looping instructions, but in a -read- error, namely one that looks like this: ./test5: line 14: read: read error: 0: Resource temporarily unavailable (line 14 is the last line in the code below) When I run this code: Code:
#!/bin/bash
function record
{
dvgrab --format raw --duration smpte=$tape_length:00 --noavc --size 0 tapename.dv
}
tape_lenght=00:00:10
record
echo -n "Test -read- command:"
read null2
My actual script is much larger (400 lines, I can post it if that might help), but I've narrowed my problem to this error. As far as I can tell executing DVgrab does something that makes -read- "temporarily unavailable" and every instance of -read- after DVgrab has this error In my larger script this has the effect of continuously applying the same variable entries (previously entered via -read-) and therefore continuously records the same clip length over and over Any ideas why this is happening or what a workaround might be would be greatly appreciated, in the above test script I thought maybe putting DVgrab in a function might help, but it seems to have had no effect... Thanks -Starcast |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|