Home: Perl Programming Help: Win32 Programming Help:
Batch scripting



awaiz
Novice

Jun 3, 2010, 10:22 PM


Views: 18341
Batch scripting

Hi All,

I m trying to write a simple batch script. Here'e my script

*********************

@ECHO OFF

echo Adding the transports to the buffer

FOR /F %%i IN (tp_list.txt) DO ( tp addtobuffer %%i PSE client=100 pf=E:\usr\sap\trans\bin\TP_DOMAIN_PSE.PFL

if %errorlevel% NEQ 0 echo Transport %%i has ended in error

GOTO END

)

:END

**********************

I want the loop to continue when error NEQ 0 and the loop to exit if error = 0. tp_list.txt has many entries if the first one ended with error = 0 then it does not go to the next line item and just exists the loop.

Any quick help will be appreciated !

thanks in advance !

Awaiz.


BillKSmith
Veteran

Jun 4, 2010, 8:20 AM


Views: 18331
Re: [awaiz] Batch scripting

Use perl.


Code
  

use strict;
use warnings;

open my $f, '<', 'tp_list.txt' or die "Cannot open tp_list.txt\n";
local $/ = undef;
my @set = split /\s/, <$f>;
close $f;
for my $tp (@set) {
system(

"tp addtobuffer $tp client=100 pf=E:\\usr\\sap\\trans\\bin\\TP+DOMAIN_PSE.PFL"
)
and die "Transport $tp has ended in error\n";
}

Good Luck,
Bill


awaiz
Novice

Jun 12, 2010, 7:22 AM


Views: 18116
Re: [BillKSmith] Batch scripting

Hi
Could you give the same code in batch ?

Awaiz