On Tue, Mar 10, 2009 at 10:37 PM, Bryan <[email protected]> wrote:
> okay, here goes...
>
> I am making a script that will help me automate conversion of movies
> to other formats.  I'm trying to set a variable $CROP and I'm trying
> to pull info from a text file created by mplayer to get the black
> lines off of the movie.  Here is the script:
>
>
> ----------------------------------------------------------------------------------------------
> #!/bin/sh
>
> mplayer -v -ss 00:15:00 -frames 20 -vf cropdetect dvd://1 > crop.txt
>
> export CROP=`tail -n 11 crop.txt | grep CROP | cut -d= -f2 | cut -c 1-11`
>
> echo $CROP
> ----------------------------------------------------------------------------------------------
>
> now, the text file creates text, and I've used the "tail - grep - cut
> - cut" command on the command line and was able to get the data I
> needed.  Also on the command line, I can export the variable (I do it
> all the time with PKG_PATH).  When I run the script, the crop.txt is
> created, and the variable prints out $CROP, but after the script ends,
> I attempt to "echo $CROP" and the variable is empty...
>
> Is there something I'm missing?  Or is there nothing wrong, and the
> script (while running) knows the value of $CROP, value of $CROP is
> dropped once the script terminates.
>

This confused me for SO LONG. The trick is to "source" the file
instead of running it as so:
. ./script
or
source ./script

You'd think "EXPORT" exports the value to the entire OS, but no, it
only exports it beyond the that command line. It sort of makes sense
in the context that can do this to pass variables to programs:
$ VAR=VAL ./script

Unix is crazy.

-Nick
_______________________________________________
Openbsd-newbies mailing list
[email protected]
http://mailman.theapt.org/listinfo/openbsd-newbies

Reply via email to