Find the answer to your Linux question:
Results 1 to 6 of 6
can the following line be turned into a script file? let x=10;while [ $x -gt 0 ];do clear; figlet $x;let x-=1;sleep 2;done Just started learning Bash and every time I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2013
    Location
    South Texas
    Posts
    28

    Trying to make sh file


    can the following line be turned into a script file?

    let x=10;while [ $x -gt 0 ];do clear; figlet $x;let x-=1;sleep 2;done

    Just started learning Bash and every time I try to run this file it comes back with the error:

    figlet.sh: command not found

    i did make it excutable. Also tried putting ./ in front of file. If it can be done just give me a hint on what I need to look at. Thanks

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    675
    For a script to run there are three things that need to be done.

    1) In the script itself it must start with a special comment (referred to as the she-bang line or hack). This is a comment line in the script as the first line:
    Code:
    #!/bin/bash
    This tells the program that reads and runs the script (in this case bash which is found in "/bin/bash").

    2) The permissions need to be changed to allow it to be executed. Here some examples of changing the permissions of a file:
    Code:
    chmod 755 filename
    
    chmod u+x filename
    3) Place the file in a directory that you have added to your PATH environment variable or include the path when executing the script (or program binary if using C, C++, FORTRAN, ADA, etc).

  3. #3
    Just Joined!
    Join Date
    Jan 2013
    Location
    South Texas
    Posts
    28
    Had done all that. The file is in my home dir. If I right click on the file from the desktop I get the option to run in terminal and it runs as it should. But from inside terminal in my home dir and typing the file name I get that error message. Doing the ls command does show the file being there. Thanks for your help.
    Ham____

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie mactruck's Avatar
    Join Date
    Apr 2012
    Location
    City of Salt
    Posts
    187
    If you would like to run your file in terminal then you need to cd to the folder then type: "./script.name" and that should run your script.

  6. #5
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    675
    open a terminal and run your script from there.

  7. #6
    Just Joined!
    Join Date
    Jan 2013
    Location
    South Texas
    Posts
    28

    Solved

    Thanks for all the in put---SOLVED---http://www.linuxforums.org/forum/images/smilies/icon_biggrin.gif

Posting Permissions

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