Operating System - HP-UX
1825941 Members
2640 Online
109689 Solutions
New Discussion

Script syntax checker or dummy execution

 
SOLVED
Go to solution
Raynald Boucher
Super Advisor

Script syntax checker or dummy execution

Hello all,
Is there a way to execute a script without taking any action.

I mean by that, perform syntax checking, logic checking (ex check if file exists) etc but not execute any command that would change any file or process (ex kill) on the system.

I want to test a script a script destined for our production environment which has mirroring enabled (the script does mount, umount, lvsplit, lvmerge, fuser -k and some) but we don't have mirroring on our development environment. I'm leery of testing it on our production environment.

I worked (long ago) on a Xerox (and later Honeywell) system that had such a facility and am wondering if there isn't a switch or environment variable I could use to do this.

Thanks
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor
Solution

Re: Script syntax checker or dummy execution

Hi:

If by "script" you mean as shell script, then you can use the '-n' switch for basic syntax checking.

# sh -n myscript

Regards!

...JRF...
melvyn burnard
Honored Contributor

Re: Script syntax checker or dummy execution

I check things using the -n siwtch for sh

sh -n scriptname
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
Raynald Boucher
Super Advisor

Re: Script syntax checker or dummy execution

Thanks,
and it works for Korn shell too.

Too bad it cannot perform non impact operations (ex tests and assignments) but then, how can it decide what has impact or not?
I guess it figures all executable files can produce actions that may have a lasting effect of the system.

Thanks again

RayB
Raynald Boucher
Super Advisor

Re: Script syntax checker or dummy execution

Thread closed