PDA

View Full Version : SHELL Scripts



Smurfman
10-04-2005, 02:46 AM
Not sure where to post this...but I am having some trouble with a Shell Script.

I am getting an error when I use the CALL command in the shell script.
While the doc and the CALL /? doc both show that a CALL :Label arguments is a
valid way of using the function, I can't seem to get it to work.

In a generic script I can make it work with something simepl like this:
Using it at the command prompt like MYTEST.BAT input text here, results in an
echo of the text inputed.

@ECHO OFF
SET ISSUED=%1
CALL :TEST %ISSUED%

GOTO :EOF

:TEST
echo hello %1
pause

:EOF

HOWEVER if I have something a little more complex: Like below, I get a Bad
Command or Filename when using the CALL function of the Shell. Any ideas why
this happening? (I over simplified the script to remove the excess fluff, and
added the debug string that I wanted to display to know where I am at
execution)...

Thanks
J


@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

REM - - - - U_CRS.BAT - - - -

CLS


IF "%1"=="1" goto ONE
IF "%1"=="2" goto TWO

GOTO EOF

:ONE
SET ISSUED="C:\PATH\PATHLOC\IN\ISSUED.DAT"
SET RAWFILE="C:\PATH\PATHLOC\IN\ISSUED.DAT"
SET BLOCK="NORMAL_BLOCK_50"

GOTO PROCESS

:TWO

SET ISSUED="C:\PATH\PATHLOC\IN\OUTPUT.DAT"
SET RAWFILE="C:\PATH\PATHLOC\IN\SEMC??????.ISSUED"
SET BLOCK="NORMAL_BLOCK_50"

GOTO PROCESS
:PROCESS

CALL :TEST %ISSUED%

echo after called test
pause

GOTO EOF

REM
************************************************** ****************************
REM *** FUNCTIONS
***
REM
************************************************** ****************************

:TEST
echo hello
echo %1
pause

:EOF
endlocal
EXIT

Smurfman
10-04-2005, 02:46 AM
One thing I forgot, which will explain something that might help...

If I browse to the script in a CMD shell and execute the script by entering
the bat file followed by the command arguments, it works just fine.

However, if I use a PIF that already has the Command Line Arguments in the
shortcut, that is where it does not work. (using the _DEFAULT PIF) This is
where things do not work properly.

Thanks
J

"Smurfman" wrote:

> Not sure where to post this...but I am having some trouble with a Shell Script.
>
> I am getting an error when I use the CALL command in the shell script.
> While the doc and the CALL /? doc both show that a CALL :Label arguments is a
> valid way of using the function, I can't seem to get it to work.
>
> In a generic script I can make it work with something simepl like this:
> Using it at the command prompt like MYTEST.BAT input text here, results in an
> echo of the text inputed.
>
> @ECHO OFF
> SET ISSUED=%1
> CALL :TEST %ISSUED%
>
> GOTO :EOF
>
> :TEST
> echo hello %1
> pause
>
> :EOF
>
> HOWEVER if I have something a little more complex: Like below, I get a Bad
> Command or Filename when using the CALL function of the Shell. Any ideas why
> this happening? (I over simplified the script to remove the excess fluff, and
> added the debug string that I wanted to display to know where I am at
> execution)...
>
> Thanks
> J
>
>
> @ECHO OFF
> SETLOCAL ENABLEDELAYEDEXPANSION
>
> REM - - - - U_CRS.BAT - - - -
>
> CLS
>
>
> IF "%1"=="1" goto ONE
> IF "%1"=="2" goto TWO
>
> GOTO EOF
>
> :ONE
> SET ISSUED="C:\PATH\PATHLOC\IN\ISSUED.DAT"
> SET RAWFILE="C:\PATH\PATHLOC\IN\ISSUED.DAT"
> SET BLOCK="NORMAL_BLOCK_50"
>
> GOTO PROCESS
>
> :TWO
>
> SET ISSUED="C:\PATH\PATHLOC\IN\OUTPUT.DAT"
> SET RAWFILE="C:\PATH\PATHLOC\IN\SEMC??????.ISSUED"
> SET BLOCK="NORMAL_BLOCK_50"
>
> GOTO PROCESS
> :PROCESS
>
> CALL :TEST %ISSUED%
>
> echo after called test
> pause
>
> GOTO EOF
>
> REM
> ************************************************** ****************************
> REM *** FUNCTIONS
> ***
> REM
> ************************************************** ****************************
>
> :TEST
> echo hello
> echo %1
> pause
>
> :EOF
> endlocal
> EXIT
>
>

Hosted by: Eyo Technologies Pty Ltd. Sponsored by: Actiontec Pty Ltd