Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
i have very good skills in C++ language –  Mohammad AL-Rawabdeh Sep 13 '10 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. –  chunkyb2002 Sep 13 '10 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 –  Iain Sep 13 '10 at 8:10

2 Answers 2

up vote 1 down vote accepted
  • 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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.