Linux Forums - Linux Help,Advice & support community:LinuxSolved.com

Linux in General => Linux Development & Programming => Topic started by: shipoin_97 on December 10, 2005, 06:29:56 AM

Title: Running shell Script
Post by: shipoin_97 on December 10, 2005, 06:29:56 AM
DeAr ,

        I am a newbie runnig shell scripting in Linux .  I have the following questions like ,

        1) If i wrte a  script  like
     
                #!/bin/bash
               #make_page - A Script to produce an HTML file
                                                                               
              title="System Information for"
            cat <<- _E OF_
<HTML>
<HEAD>
     <TITLE>
         $title $shipon
     </TITLE>
</HEAD>
                                                                               
 <BODY>
    <H1>$title $shipon</H1>
</BODY>
 </HTML>
                                                                               
_EOF_
                                                                               
            How can i run it ? or using which cammand i  show my system information .


2 ) if  i  write the following script

              function system_info
{
    echo "<h2>System release info</h2>"
    echo "<p>Function not yet implemented</p>"
}

 How i can run it ?

                          Plz help me ........
Title: Running shell Script
Post by: dragoncity99 on December 14, 2005, 01:56:18 PM
If u wan to run the script u have to change ur script to executable file first.

# chmod +x your-script.sh

To run it:
# ./your-script.sh

To run a function:
1. Your function must be at the top most of the script after #!/bin/bash or #!/bin/sh
2. To initiate/call the function just type name of the function:

Code: [Select]

#!/bin/sh
myfunction(){
  echo "HelloWorld"
}

# Just call the function name
myfunction


Got it?