BSD Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsBSD Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 8th, 2009, 12:20 AM
brakeb brakeb is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Posts: 3 brakeb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 sec
Reputation Power: 0
Shell script not setting variables

I'm /bin/sh as the shell for this script. I'm attempting to create a script that will automate the ripping of DVDs into a format to be named later. So far, I'm able to take the output of Mplayer/mencoder and create a file called "crop.txt".

when I run the script, though, crop.txt is created, but the variables I want to set don't get set...

what am I doing wrong? I'm sure it's something very minor...

-------------------------------------------------------------------------------------------------------------
#!/bin/sh

mplayer -v -ss 00:15:00 -frames 20 -vf cropdetect dvd://1 > crop.txt

CROP='tail -n 11 crop.txt | grep CROP | cut -d= -f2 | cut -c 1-11'
-------------------------------------------------------------------------------------------------------------

now, I've run these commands independently, and the output from

"tail -n 11 crop.txt | grep CROP | cut -d= -f2 | cut -c 1-11"

is "720:480:0:0". I want this set as $CROP, so that later in the script, I can call that variable.

Any assistance is greatly appreciated...

Please keep the scope to only /bin/sh. I have no interest in using csh, bash, or anything like that... /bin/sh is ubiquitous to all UNIX systems.

Bryan

Last edited by brakeb : March 8th, 2009 at 12:29 AM. Reason: added notification

Reply With Quote
  #2  
Old April 10th, 2009, 09:21 AM
iamroot iamroot is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2008
Posts: 96 iamroot User rank is First Lieutenant (10000 - 20000 Reputation Level)iamroot User rank is First Lieutenant (10000 - 20000 Reputation Level)iamroot User rank is First Lieutenant (10000 - 20000 Reputation Level)iamroot User rank is First Lieutenant (10000 - 20000 Reputation Level)iamroot User rank is First Lieutenant (10000 - 20000 Reputation Level)iamroot User rank is First Lieutenant (10000 - 20000 Reputation Level)iamroot User rank is First Lieutenant (10000 - 20000 Reputation Level)iamroot User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 20 h 57 m 33 sec
Reputation Power: 140
If you are going to run commands and assign the output to a variable you need to make sure you use the right quotes. ( i.e. the ones on the tilde[~] key ) I can't remember what they're actually called.. but here's your example with the correct quotes.

CROP=`tail -n 11 crop.txt | grep CROP | cut -d= -f2 | cut -c 1-11`

also, you can always run your script in debug mode to watch these things.

sh -x ./script.sh

or change the shebang to

#!/bin/sh -x

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsBSD Help > Shell script not setting variables

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap