0

I am new to Unix shell scripting. So can anybody help me?

How to write shell scripts in Sun Solaris? How to run/execute the script?

Please post in detail.

splattne
  • 28,508
  • 20
  • 98
  • 148
Mohammad AL-Rawabdeh
  • 1,612
  • 12
  • 33
  • 54
  • i have very good skills in C++ language – Mohammad AL-Rawabdeh Sep 13 '10 at 07:50
  • Shell scripting is very different to c++ so the learning curve might be quite steep. Check out http://www.freeos.com/guides/lsst/ its aimed at Linux OS's but the principles are largely the same. – chunkyb2002 Sep 13 '10 at 08:07
  • This is outside the scope of server fault. A common shell to script in is bash - you can find an introduction to bash scripting [here](http://tille.garrels.be/training/bash/) – user9517 Sep 13 '10 at 08:10

2 Answers2

2

It is not very different from writing a shell script in Linux. Some pitfalls:

  • Relying on GNU tools, but not installed (sed, awk, grep -r etc.)
  • Path names (if you use bash, prefix all your scripts with #!/usr/bin/env bash

I suggest you to read http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html.

weeheavy
  • 4,089
  • 1
  • 28
  • 41
1
  • create script file, first row beginning with this: #!/bin/sh -
  • add script body (echo Hello world) on following lines after that.
  • make script executable (chmod u+x scriptfile)
  • either put scriptfile somewhere in your path, or invoke it by its pathname.

./scriptfile is the relative pathname if your current directory is where you put the script.

MattBianco
  • 597
  • 1
  • 7
  • 23