Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

running a perl script in a isql while loop

2 posts in General Discussion Last posting was on 2010-02-18 23:48:46.0Z
tartampion Posted on 2010-02-18 21:44:12.0Z
Sender: 43c7.4b7ace7f.1804289383@sybase.com
From: tartampion
Newsgroups: sybase.public.ase.general
Subject: running a perl script in a isql while loop
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4b7db4ac.3e86.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 18 Feb 2010 13:44:12 -0800
X-Trace: forums-1-dub 1266529452 10.22.241.41 (18 Feb 2010 13:44:12 -0800)
X-Original-Trace: 18 Feb 2010 13:44:12 -0800, 10.22.241.41
Lines: 59
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28980
Article PK: 78218

Hi all,

I guess that all of us run scripts from isql, at least
during a development phase.

I tried to run in my isql session a perl script in a while
loop:
isql ....

while (1 =1 )
begin
if exists(select 1 from ....)
begin
select "I am going to run the perl script
!! perl perl_script.pl params
select " Ran teh perl script, will wait for 10
seconds"
waitfor delay '00:00:10'
end
else
begin
select "we are getting out of the loop"
break
end
end
go

When the script is run , the perl script is executed for teh
first time, but from the second set of loop, it is not
anymore run.
here is an example of out come:
First run
[sh:"perl d:/aaaa/batch/per_script.pl"]
I go into the perl ----> message coming from inside of the
perl script

------------------------ --------------------------
Not Done Yettttttttttttt Feb 18 2010 4:39PM

(1 row affected)

------------ --------------------------
Not Done Yet Feb 18 2010 4:39PM

(1 row affected)
second and third run:
------------------------ --------------------------
Not Done Yettttttttttttt Feb 18 2010 4:39PM

(1 row affected)

------------ --------------------------
Not Done Yet Feb 18 2010 4:39PM

(1 row affected)

------------------------ --------------------------

What is the reason for such a behavior?


Luc Van der Veurst Posted on 2010-02-18 23:48:46.0Z
From: "Luc Van der Veurst" <dba_azvub@hotmail.com>
Newsgroups: sybase.public.ase.general
References: <4b7db4ac.3e86.1681692777@sybase.com>
Subject: Re: running a perl script in a isql while loop
Lines: 102
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
X-RFC2646: Format=Flowed; Original
X-Forwarded: by - (DeleGate/5.8.7)
X-Forwarded: by - (DeleGate/5.8.7)
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b7dd1de$1@forums-1-dub>
Date: 18 Feb 2010 15:48:46 -0800
X-Trace: forums-1-dub 1266536926 10.22.241.152 (18 Feb 2010 15:48:46 -0800)
X-Original-Trace: 18 Feb 2010 15:48:46 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28981
Article PK: 78219

isql parses your code and sends everything between go's (a batch) to the
dataserver.
When it encounters the !!perl line, it executes that immediately, it's not
part of the batch. So it's only parsed once and it's not part of the
batch sent to the server, so it's only executed once.

You'll see that when you execute the statement interactively.

If you enter the following ;

select 1
!!echo "an echo"
select 2
go

The output of echo will appear before you type "select 2", the output will
look
like :

1> select 1
2> !!echo "an echo"
[sh:echo "an echo"]
an echo
2> select 2
3> go

-----------
1

(1 row affected)

-----------
2

(1 row affected)
1>

Luc.

<tartampion> wrote in message news:4b7db4ac.3e86.1681692777@sybase.com...
> Hi all,
>
> I guess that all of us run scripts from isql, at least
> during a development phase.
>
> I tried to run in my isql session a perl script in a while
> loop:
> isql ....
>
> while (1 =1 )
> begin
> if exists(select 1 from ....)
> begin
> select "I am going to run the perl script
> !! perl perl_script.pl params
> select " Ran teh perl script, will wait for 10
> seconds"
> waitfor delay '00:00:10'
> end
> else
> begin
> select "we are getting out of the loop"
> break
> end
> end
> go
>
> When the script is run , the perl script is executed for teh
> first time, but from the second set of loop, it is not
> anymore run.
> here is an example of out come:
> First run
> [sh:"perl d:/aaaa/batch/per_script.pl"]
> I go into the perl ----> message coming from inside of the
> perl script
>
> ------------------------ --------------------------
> Not Done Yettttttttttttt Feb 18 2010 4:39PM
>
> (1 row affected)
>
> ------------ --------------------------
> Not Done Yet Feb 18 2010 4:39PM
>
> (1 row affected)
> second and third run:
> ------------------------ --------------------------
> Not Done Yettttttttttttt Feb 18 2010 4:39PM
>
> (1 row affected)
>
> ------------ --------------------------
> Not Done Yet Feb 18 2010 4:39PM
>
> (1 row affected)
>
> ------------------------ --------------------------
>
> What is the reason for such a behavior?