Wednesday, June 13, 2007

Solaris Shell Scripting: Part 1

Shell scripting is suppose to be universal if you use #!/bin/sh. Yet, some if my scripting tricks are not working. A few notes:

Suppressing carriage return (CR):
Linux: echo -n "Hello "; echo "World"
Solaris: echo "Hello \c"; echo "World"

Capturing keyboard input:
Linux: prompt -p "Input: " VAR
Solaris: echo "Input: \c"; prompt VAR

Single command conditionals:
Linux: if [ -f /etc/passwd ]; then echo "Go"
Solaris: if [ -f /etc/passwd ]; then echo "Go"; fi

Finite count loop:
Linux:for X in {1..5}; do echo $Z; done
Solaris: X=0; while [ $X -lt 5 ]; do X=`expr $X + 1`; echo $X; done

No comments:

Post a Comment