Using sh/csh, unfortunately shell scripts are not my strong suit.
Trying to write a script that gets called from a program for pre-processing.
The program passes individual components of a UNC (//server/path1/path2/filename).
Thus the unc path of: //server/path1/path2/filename, is 4 calls to myscript with each call having a single parameter of:
//server
//server/path1
//server/path1/path2
//server/path1/path2/filename
I need to be able to determine if the current component is the Server component or not. ie: //server not //server/blah.
Figured that would be easy ... Something simple like:
RESULT=`echo "$1" | sed -e '/^\/\/.+\//p'`
if [ ! "$RESULT" ]; then
echo "Server Component"
else
echo "Path components"
fi
should get it done, Obviously I was wrong.
How can I go about this or what am I doing wrong?
The Server component will always begin with two slashes followed by a name, no trailing slash.
Non server components will always have two leading slashes, the server name followed by a slash ... and more.
If it does not start with two leading slashes it should be completely ignored.
Ruby and AWK are out ... not available.
That is the reason for my second line in original post. sh/csh!
sed is available.
I am not Reading or Processing a file ...
A Single parameter is passed to myscript, that parameter will contain ONE part of a path.
In myscript, it is referenced by $1.
I need to know if that one component (in $1) is the server part or not (ie: //server and not //server/blab) ... Thats all!
Obviously this will be used for flow control. as per my example in the original post.