The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Associated array from command line options jperret Shell Programming and Scripting 1 01-10-2008 01:16 PM
launch a command only if Minguccio75 UNIX for Advanced & Expert Users 10 02-16-2007 03:48 AM
Split Command options mohdtausifsh UNIX for Advanced & Expert Users 7 10-04-2006 04:28 AM
replacing a string in a file with command line parameter chiru_h Shell Programming and Scripting 5 08-03-2006 06:34 AM
Executing command line options Safia High Level Programming 8 07-04-2002 12:50 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-14-2008
Registered User
 

Join Date: Mar 2008
Posts: 13
how to? launch command with string of command line options

my description from another thread...
Quote:
The other script I've got that I'd love to get working is one I wrote to combine a series of avi files using avidemux. to do this I wrote a script that takes the input files as the arguements, deduces the output file name and then because of avidemux's arguement procedure I have it create a set of strings that it needs to append to the call to avidemux for each file being added to the original. What I've done with this one is have it echo the required command to run which I can then copy and paste and it works fine, but it would be much nicer if I could get it to actually *launch* said command.
here's my code:
Code:
#!/bin/bash
IFS=$'\n'

function OutputName() {
        input=$1
        echo $input
        input=`echo "$input" | sed -e 's/.[Aa][Vv][Ii]//'`
        input=`echo "$input".avi`
        output_name=$input
}

if [[ -z "@ARGV" ]]; then
        echo "arguements are files to combine"
        exit
else
        if [[ ! -e $1 ]]; then
                echo "no such input video!"
                exit
        else
                first=`find "$1" -printf "%f"`
                echo "Input File Found!: $first"
                shift
        fi
        OutputName $first
        echo "Output video name will be: "$output_name""
        echo
fi

options="--audio-map --force-b-frame --force-unpack --rebuild-index"

appendlist=""

until [ -z "$1" ]
do
#       echo "$1"
#       echo "$appendlist"
        if [[ ! -e $1 ]]; then
                echo "no such input video! $1"
                exit
        else
                filename=`find "$1" -printf '"%f"'`
                appendlist="$appendlist $options --append $filename"
        fi
#       echo "$appendlist"
#       echo
        shift
done

echo "avidemux2_cli --nogui $options --load \"$first\" $appendlist --force-smart --save \"$output_name\" --quit"
thanks for the help!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-16-2008
era
Guest
 

Posts: n/a
I didn't read your code too carefully, so I could have missed something, but is there anything wrong with

Code:
echo 'some "command" --with options' | sh
You can have your variants, of course.

Code:
dhummy=`some "command" --with options`
Code:
fnord='some "command" --with options'
eval $fnord
etc etc.
Reply With Quote
  #3 (permalink)  
Old 03-23-2008
Registered User
 

Join Date: Mar 2008
Posts: 13
because I get this as the output:

Quote:
../combine-0.1: line 50: avidemux2_cli --nogui --audio-map --force-b-frame --force-unpack --rebuild-index --load "inputfile1.avi" --audio-map --force-b-frame --force-unpack --rebuild-index --append "inputfile2.avi" --force-smart --save "inputfile.avi" --quit: command not found
Reply With Quote
  #4 (permalink)  
Old 04-01-2008
Registered User
 

Join Date: Mar 2008
Posts: 13
anyone know why this is failing?
Reply With Quote
  #5 (permalink)  
Old 04-28-2008
Registered User
 

Join Date: Mar 2008
Posts: 13
requesting help again, thanks!
Reply With Quote
  #6 (permalink)  
Old 04-28-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,084
How exactly did you manage to produce that error message? It looks like you had double-quoted the whole command, where you shouldn't.

If you change it back to echo, doesn't ../combine-0.1 | sh do what you want?
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:40 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0