Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Simple bash file.

    First off I would like to say that I have googled my answer before coming here but I've had no luck(or maybe im blind :P)
    All I want is to create a bash file that opens terminal, cd to a directory and runs a command. I've had no luck with getting this to work. Any help?

  2. #2
    Linux Enthusiast
    Join Date
    Dec 2011
    Turtle Island West
    There's a few options here.

    If the command is simple:
    cd $DIR; xterm -e $COMMAND
    Or, if the command is complex or variable, make a shell script,, and do chmod +x, and put it somewhere in your $PATH:
    cd $DIR
    $COMMAND $arg1 $arg2 $arg3 can be as complicated as you like.
    and then
    xterm -e
    Of course, change $DIR with the real directory, and $COMMAND with the real command.

    I use this all the time to create a menu of various config options, for example. Once the script terminates, the xterm goes away too. If you want to see the output of the command, put a 'read' at the end of the script so it will wait for a keypress before closing.

    Hope that helps.

  3. #3
    Thanks. That helped a lot

  4. $spacer_open

Posting Permissions

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