Find the answer to your Linux question:
Results 1 to 8 of 8
i was reading on shell scripting and i understand it and kind dont. I wanted to make a script that automatically converts .avi into mpeg. I use a program called ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    57

    shell scripting help

    i was reading on shell scripting and i understand it and kind dont. I wanted to make a script that automatically converts .avi into mpeg. I use a program called tovid which is all command line here is the command you would type

    tovid -wide -ntsc -in (your video here) -out _encoded

    how would you make that into excutable script. is this somewhat on how you would do it

    $
    #
    # conerting avi into mpeg
    #
    echo tovid -wide -ntsc -in some video.avi -out _encoded
    clear
    ?

    Am i close or at all. Alittle lost. Appreciate the help.

    Thanks

  2. #2
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,096
    UndergroundX, I've moved this to the programming & scripting forum because you're more likely to get help here.

    Good luck with it...
    oz

    new members/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

  3. #3
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Right. Well, a single command, you can obviously execute on your own from the command line. But you could put it into a script for fun, or if you wanted to automatically run it on every AVI, or anything like that.

    So let's look at your script so far:

    Your first line invokes the echo command with a bunch of arguments. However, all that echo does is print something to the screen. You don't want to echo the command, you want to actually want to run it. In a script, the actual command run is the first entry in a statement. A statement is either semicolon-terminated or newline-terminated. So in your script, you have two statements (the echo, and the clear).

    How can you change from printing out the command to actually running it?

    Also, what are you lost on? If you have a specific question, it will help us help you.
    DISTRO=Arch
    Registered Linux User #388732

  4. #4
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    tovid is a script having bunch of commands that convert avi. to .mpeg. and you are just adding a few more commands before and after calling tovid script in your own script.

    I would suggest you to start from here : linuxcommand.org and learn a bit about scripting stuff. You will start creating your own scripts pretty soon.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  5. #5
    Just Joined!
    Join Date
    Oct 2007
    Posts
    57

    lost

    Oh ok. cause i was reading on howto set it up and it all looks confusing i mean if you mess up just a single line of text the whole script is ruined. Anyways i need help with how to properly make the script. I know from what i inserted was wrong. I wanted someone to help me correct it so that i can execute it say when i wanna convert some video.avi to mpeg all i have to do is. ./script and then thats it. #!bin/bash or sh does that have to be in there at all. If not how come it doesnt have to be?

  6. #6
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    As I have suggested earlier, check linuxcommand.org. You will learn a lot of stuff from there.
    Do post back after reading first 3-4 chapters.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  7. #7
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    I would also suggest reading:
    http://tldp.org/LDP/Bash-Beginners-G...tml/index.html

    That guide will also answer your question about the shebang line (the "#!" line).
    DISTRO=Arch
    Registered Linux User #388732

  8. #8
    Just Joined!
    Join Date
    Oct 2007
    Posts
    7

    Read up! :)

    Hey there,

    As everyone has pretty much already stated is read up on basic scripting and you'll definitely get it. It's quite simple if you first think about the logic behind it and then use the appropriate commands to make your script work.

    For example on your script something like this would work, of course this all depends on _how_ you want your script to work...

    Script: myscript

    Code:
    #!/bin/bash
    
    # Command syntax: myscript <avi file>
    tovid -wide -ntsc -in $1 -out _encoded
    or process all avi folders in current directory...

    Code:
    #!/bin/bash
    
    files=`ls $PWD |grep -i .avi`
    
    for file in $files
    do
    tovid -wide -ntsc -in $file -out _encoded
    done
    Good luck.

    Scorp

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...