November 22, 2024, 08:51:58 AM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: Running shell Script  (Read 6240 times)

Offline shipoin_97

  • Tux Awared
  • **
  • Posts: 44
Running shell Script
« 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 ........

Offline dragoncity99

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 551
Running shell Script
« Reply #1 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?