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.

3
  • i have very good skills in C++ language Sep 13, 2010 at 7:50
  • Shell scripting is very different to c++ so the learning curve might be quite steep. Check out freeos.com/guides/lsst its aimed at Linux OS's but the principles are largely the same. Sep 13, 2010 at 8: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
    – user9517
    Sep 13, 2010 at 8:10

2 Answers 2

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.

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .