Re: RUN and the shell
Posted in 1995
Topics: Server Administration
Thanks to all who replied, all hints much appreciated, sadly there was no special informix setting to be used but as they say, 'That's life'<g> What I have found is as follows: For an existing program which invokes shell commands using the RUN statement (ie. RUN ls *.log >/dev/null 2>&1 ) you need to set the environment variable SHELL to the appropriate shell and export it so that it is picked up correctly. # save current shell SAVESHELL=$SHELL # set shell required SHELL=/bin/sh export SHELL # run da program fglgo myprogram # restore shell SHELL=$SAVESHELL export SHELL For new code the following two methods are workable, RUN /bin/sh -c 'ls *.log >/dev/null 2>&1' RETURNING runrc or using a script file (must be executable of course) ------------------ /bin/sh -c '$*' ------------------ thus RUN myshell 'ls *.log >/dev/null 2>&1' RETURNING runrc You can get away without '/bin/' if you're confident of having it in the path (which may not be the case in some cron situations I think). You do not need #!/bin/sh in the script file as you're explicitly invoking the shell. I tried ----------------- #!/bin/sh $* ----------------- but alas redirection does not get interpretted correctly. :-( It may be of no concern to many who use #!/bin/sh but it certainly is to me.<g> Cheers, Ian. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Ian Timms (DBA/Administrator) % Disclaimer: All opinions expressed % % itimms@vprp333q.prop.telecom.com.au % herein are mine and mine alone! % % Ph. 61+3+634-9144 % ==__( pretty piccy goes here )__== % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%