how to? launch command with string of command line options | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

how to? launch command with string of command line options

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-14-2008
TinCanFury TinCanFury is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 28 December 2008, 8:11 PM EST
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
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!
Sponsored Links
    #2  
Old 03-17-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.
Sponsored Links
    #3  
Old 03-23-2008
TinCanFury TinCanFury is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 28 December 2008, 8:11 PM EST
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
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
    #4  
Old 04-01-2008
TinCanFury TinCanFury is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 28 December 2008, 8:11 PM EST
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
anyone know why this is failing?
Sponsored Links
    #5  
Old 04-28-2008
TinCanFury TinCanFury is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 28 December 2008, 8:11 PM EST
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
requesting help again, thanks!
Sponsored Links
    #6  
Old 04-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
 
Join Date: Mar 2008
Last Activity: 28 March 2011, 6:41 AM EDT
Location: /there/is/only/bin/sh
Posts: 3,653
Thanks: 0
Thanked 10 Times in 8 Posts
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?
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Running set options from the command line and bash command Straitsfan UNIX for Dummies Questions & Answers 5 07-28-2011 11:27 AM
awk script file command line options tomr2k Shell Programming and Scripting 2 06-30-2011 02:55 AM
Using perl to get options from command line Damon_Qu Shell Programming and Scripting 1 07-01-2010 10:17 PM
Associated array from command line options jperret Shell Programming and Scripting 1 01-10-2008 04:16 PM
Executing command line options Safia Programming 8 07-04-2002 03:50 AM



All times are GMT -4. The time now is 11:55 AM.