[13347] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 757 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 10 09:07:29 1999

Date: Fri, 10 Sep 1999 06:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 10 Sep 1999     Volume: 9 Number: 757

Today's topics:
    Re: back for more sorting abuse (Anno Siegel)
        buying perl book (Help me) sine2117@my-deja.com
    Re: buying perl book (Help me) <NOSPAMmark@nl.gxn.net>
    Re: Comparing against today's date? <flavell@mail.cern.ch>
    Re: converting a number into a binary? (Anno Siegel)
        is it perl BUG !? (Ryan Ngi)
        Perl build on SCO Openserver 5.0.5 <gellyfish@gellyfish.com>
        perl script problem (knoxy.com)
    Re: Printing characters in reverse-video to screen <pj@produktiv.com>
        Sell a product which costs nothing to produce! nobody@nowhere33.yet
    Re: Services in Perl <carvdawg@patriot.net>
    Re: Services in Perl <xxx@kmd.dk>
    Re: Win32::ODBC help <carvdawg@patriot.net>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 10 Sep 1999 12:41:31 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: back for more sorting abuse
Message-Id: <7rau9r$b0q$1@lublin.zrz.tu-berlin.de>

Uri Guttman  <uri@sysarch.com> wrote in comp.lang.perl.misc:

>well, you want to eliminate that slow sort sub. time for some more
>reading and studying. check out this award winning paper <gloat!> on
>faster sorting:
>
>http://www.sysarch.com/perl/sort_paper.html

Award?  Do tell.

Anno


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

Date: Fri, 10 Sep 1999 10:43:40 GMT
From: sine2117@my-deja.com
Subject: buying perl book (Help me)
Message-Id: <7rancr$364$1@nnrp1.deja.com>

Hello, anyone have a good tip of a nice perl book. like perl cookbook or
something ?


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 10 Sep 1999 13:15:24 +0200
From: "Me" <NOSPAMmark@nl.gxn.net>
Subject: Re: buying perl book (Help me)
Message-Id: <7rapb8$e6h$1@blue.nl.gxn.net>

Learning Perl,
Programming Perl
Advanced Perl Programming
Perl Cookbook
Perl in a Nutshell

I'm a newbie but I bought them all at the
same time, .. kinda stimulates me more and more.......

Very well written, clear explanations and a bit or humor
here and there to keep your mind on the programming

Mark

--
Mark Spring                   GX Networks B.V.
email: mark@nl.gxn.net        Televisieweg 2
tel: +31 36 5462400           1322 AC  Almere
fax: +31 36 5462424           The Netherlands


<sine2117@my-deja.com> wrote in message news:7rancr$364$1@nnrp1.deja.com...
> Hello, anyone have a good tip of a nice perl book. like perl cookbook or
> something ?
>
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.




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

Date: Fri, 10 Sep 1999 12:42:35 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Comparing against today's date?
Message-Id: <Pine.HPP.3.95a.990910123226.27088E-100000@hpplus03.cern.ch>

On Thu, 9 Sep 1999, Michael de Beer wrote:

> I think your split/compare with localtime strategy is good.
> You might also look at some of the Date modules in CPAN.

When someone asks about comparing dates, it always makes me uneasy.
Dates where, and by what definition?

Quite apart from the fact that in an Internet context, the date at the
prime meridian, the date at the client, the date at the actual server
and the date at the HQ of the enterprise that's running the server, are
not necessarily the same, let me share an experience with the HAFAS
timetable server. 

Some railway administrations describe their operations aftger midnight
until the close of service (or until some nominal time, e.g 03:00) as
belonging to the previous day's date.  Thus a service that leaves at
00:15 on Saturday night is counted by its operators as belonging to
Saturday and is listed as such in their database; but the timetable
server takes their data literally and thinks it operates in the early
hours of Saturday, i.e on Friday nights.  Woops.




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

Date: 10 Sep 1999 10:39:17 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: converting a number into a binary?
Message-Id: <7ran4l$at5$1@lublin.zrz.tu-berlin.de>

Larry Rosler <lr@hpl.hp.com> wrote in comp.lang.perl.misc:

[conversion to binary]

>I recall that Perl 5.6 will have 'b' conversions in sprintf, but I'm 
>still trying to figure out how best to solve this problem without them.

One may as well go all the way and convert from any base to any other.
As usual, the subject is dealt with neatly and thoroughly in Don Knuth,
_The Art of Computer Programming_, in this case volume 2 (Seminumerical
Algorithms), section 4.4.

Neglecting signs (i.e. dealing with non-negative numbers only), Knuth
splits the problem of converting from radix b to radix B along two
criteria:  (1) Dealing with integers vs. (2) dealing with fractions
(fractions being numbers x with 0 <= x < 1), and using (a) radix b
arithmetic (the base we're coming from) vs. using (b) radix B
arithmetic (the base we're going to) and suggests four corresponding
algorithms.

In a Perl implementation it is natural to represent numbers in the
base we're doing arithmetic in (home base?) as scalars while using
arrays of digits for the foreign base.  Thus we get four subroutines:

(1a) Turn an integer into a list of digits (radix point to the right)
(1b) Turn a list of digits (radix point to the right) into an integer 
(2a) Turn a fraction into a list of digits (radix point to the left)
(2b) Turn a list of digits (radix point to the left) into a fraction

As usual this neat scheme turns a little murky once you look closer:
Routines 1a, 1b and 2b are content with two parameters: a base and
a number or list of digits.  For 2b, however we need to say how many
digits we want in the resulting list, since the given fraction may not
have a finite representation in the target base.  This also brings up
the question of rounding.  Rounding, in its turn, may in rare cases
lead to a result of 1, which is not a fraction in the sense of 0 <= x
< 1 and breaks the assumption that the result is a list of digits with
the radix point to the left.  In my implementation below I have
sidestepped the rounding problem by returning truncated results.

Anno

#!/usr/bin/perl -w
use strict;

### Demo of binary conversion

my $bin = '10100100.100101';
my $num = bin_to_num( $bin);
my $bin1 = num_to_bin( $num, 6);
print "$bin -> $num -> $bin1\n";

$num = 1234.56;
$bin = num_to_bin( $num, 8);
my $num1 = bin_to_num( $bin);
print "$num -> $bin -> $num1\n";

### Application:  Convert from and to binary

sub num_to_bin {
  my $num = shift;
  my $places = shift;
  my $int = int $num;
  my $frac = $num - $int;
  join '', int_to_digits( 2, $int), '.', frac_to_digits( 2, $frac, $places);
}

sub bin_to_num {
  my $bin = shift;
  my ( $pre, $post) = split m/\./, $bin;
  digits_to_int( 2, split '', $pre) + digits_to_frac( 2, split '', $post);
}

##################################################################

# Radix conversion according to Knuth, _Seminumerical Algorithms_
# 1968 edition, p 280 ff

sub int_to_digits {          # Knuth Method (1a)
  my ( $base, $int) = @_;    # $base is the target base

  # Given a base and an integer, return the list of digits representing
  # the integer

  my @digits;
  while ( $int ) {
    unshift @digits, $int%$base;
    $int = int $int/$base;
  }
  @digits;
}
  
sub digits_to_int {           # Knuth Method (1b)
  my ( $base, @digits) = @_;  # $base is source base

  # Given a base and a list of digits, return the corresponding
  # integer

  my $int = 0;
  while ( @digits ) {
    $int = $base*$int + shift @digits;
  }
  $int;
}

sub frac_to_digits {           # Knuth Method (2a)
  my ( $base, $frac, $places) = @_;

  # Given a base, a fraction (0 <= $frac < 1) and a number of places,
  # return the list of digits to the right of the radix point,
  # truncated to the number of places

  my @digits;
  for ( my $i = 0; $i < $places; $i++ ) {
    push @digits, int $frac*$base;
    $frac = $frac*$base - int $frac*$base;
  }
  @digits;
}

sub digits_to_frac {
  my ( $base, @digits) = @_;

  # Given a base and a list of digits to the right of the radix point,
  # return the corresponding fraction

  my $frac = 0;
  while ( @digits ) {
    $frac = ( $frac + pop @digits)/$base;
  }
  $frac;
}


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

Date: Fri, 10 Sep 1999 12:17:41 GMT
From: ryanngi@hotmail.com (Ryan Ngi)
Subject: is it perl BUG !?
Message-Id: <37d8f07b.170322600@news.inet.co.th>

while i was testing my fool-algorithm -- it's about
finding   ($c**$d) mod $n where $c,$d are such big integers
($c=63709,$d above 30000 respectively)
so i have to mod and then multiply and mod then multiply ...

it's :

modmul(63709,100000,70747);

sub modmul{
        (my $i,my $d,my $n)=@_;
        my $static=$i;
        my $counter=1;

        while($counter != $d)
        {
	print "$i % $n = ";      # this line for debug result

                $i=$i % $n;

	print "$i\n";		      # this line for debug result
	print "$i * $static = ";          # this line for debug result

                $i=$i * $static;

	print "$i\n"; 	      # this line for debug result

                ++$counter;
        }


        $i=$i % $n;

        return $i;
}

the debug result during the starting time work well ,it is:

63709 % 70747 = 63709
 63709 * 63709 = 4058836681
4058836681 % 70747 = 10544
 10544 * 63709 = 671747696
671747696 % 70747 = 4931
 4931 * 63709 = 314149079
314149079 % 70747 = 32399
 32399 * 63709 = 2064107891
2064107891 % 70747 = 64166
 64166 * 63709 = 4087951694
4087951694 % 70747 = 48540
 48540 * 63709 = 3092434860
3092434860 % 70747 = 12743
 12743 * 63709 = 811843787
811843787 % 70747 = 21962
 21962 * 63709 = 1399177058
1399177058 % 70747 = 13639
 13639 * 63709 = 868927051
868927051 % 70747 = 12397
 12397 * 63709 = 789800473
789800473 % 70747 = 51712
 .................
 ....


but something happend then :

10944 * 63709 = 697231296
697231296 % 70747 = 19611
 19611 * 63709 = 1249397199
1249397199 % 70747 = 5179
 5179 * 63709 = 329948911
329948911 % 70747 = 55650
 55650 * 63709 = 3545405850
3545405850 % 70747 = 61439
 61439 * 63709 = 3914217251
3914217251 % 70747 = 68729
 68729 * 63709 = 4378655861
4378655861 % 70747 = 65611
 65611 * 63709 = 4180011199
1000 % 70747 = 1000		<============ OOH GOD
 1000 * 1000 = 1000000
1000000 % 70747 = 9542
 9542 * 1000 = 9542000
9542000 % 70747 = 61902
 61902 * 1000 = 61902000
61902000 % 70747 = 69122
 69122 * 1000 = 69122000
69122000 % 70747 = 2181
 2181 * 1000 = 2181000
 ...............
 .....

you see, the mark line should print 4180011199 % 70747 = someinteger
why $i changed to 1000 unexpectedly !?

is it a perl bug???
or something overflow !

my computer can test a perl program to compute 2**1023
it's very big integer ( java can only compute 2**62 in "long" type)

so the 4180011199 is so small for perl.... why the error rose

ps. i try to use this alogorithm to compute a RSA homework... but can
do only 8 bits because this error..............................


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

Date: 10 Sep 1999 13:56:20 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Perl build on SCO Openserver 5.0.5
Message-Id: <37d8fff4_2@newsread3.dircon.co.uk>

I have just built Perl 5.005.03 on SCO Openserver 5.0.5 with the the
Openserver development kit 5.1.1a.

It appears to build OK however I get a worrying failure in the tests:

lib/sdbm...........Can't load '../lib/auto/SDBM_File/SDBM_File.so' for module 
SDBM_File: dynamic linker: ./perl: invalid relocation type 3 at 0x804cd2d4 
at ../lib/DynaLoader.pm line 169.

at lib/sdbm.t line 14

I subsequently tried to build a couple of modules (DBI notably) and they
failed their tests after dumping core.

Has anyone seen this and fixed it before or perhaps give me an idea what
would give rise to this 'invalid reloacation' in the dynamic loader so I
can try to fix it myself.

Any help appreciated.

Usual details follow.

/J\


# uname -X

System = SCO_SV
Node = pigment
Release = 3.2v5.0.5
KernelID = 98/07/02
Machine = PentII
BusType = ISA
Serial = 5FL004460
Users = 5-user
OEM# = 0
Origin# = 1
NumCPU = 1

# perl -V
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=sco, osvers=3.2v5.0.5, archname=i386-sco
    uname='sco_sv pigment 3.2 5.0.5 i386 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O0', gccversion=
    cppflags='-U M_XENIX -D PERL_SCO -D PERL_SCO5 -w0 -belf'
    ccflags ='-U M_XENIX -D PERL_SCO -D PERL_SCO5 -w0 -belf'
    stdchar='unsigned char', d_stdstdio=undef, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=undef, longlongsize=, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='ld', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /shlib /lib /usr/lib /usr/ccs/lib
    libs=-lintl -lsocket -lnsl -lndbm -ldbm -lld -lm -lc -lcrypt -lPW -lx
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Bexport -L/usr/lo
cal/lib'
    cccdlflags='-Kpic', lddlflags='-G -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Built under sco
  Compiled at Sep 10 1999 13:39:21
  @INC:
    /usr/local/lib/perl5/5.00503/i386-sco
    /usr/local/lib/perl5/5.00503
    /usr/local/lib/perl5/site_perl/5.005/i386-sco
    /usr/local/lib/perl5/site_perl/5.005
    .


-- 
"Report accuses Royal Opera House of 'arrogance and elitism'. Report
further alleges that Pope is Catholic. Report further claims that bears
may well indeed defecate in the woods" - Private Eye


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

Date: 10 Sep 1999 11:55:07 GMT
From: gobbly@aol.com (knoxy.com)
Subject: perl script problem
Message-Id: <19990910075507.08451.00004411@ng-fr1.aol.com>

Hi there,
I'm having trouble getting a particular script to run on my web site. It's
supposed to be a message board. The URL of the message board is supposed to be:
www.knoxy.com/cgi-local/config.pl
I have chmod 755'd the .pl files and uploaded them in ASCII format. But all I
get is the server hangup error message, and other people have reported
different error messages. I have pasted the script below for anyone to look at
to see if it's my mistake... though it probably is <g>. Any ideas? If you need
more information, don't hesistate to post or email me back. Thanks, Andrew

#!/usr/bin/perl

## (1) Define the location of your files:

require "/cgi-local/webbbs.pl";
require "/cgi-local/webbbs_text.pl";

$dir = "/cgi-local";
$cgiurl = "http://www.knoxy.com/cgi-local/config.pl";

## (2) Tailor the appearance and functionality of your BBS:

$UseLocking = 1;

$bodyspec = "BGCOLOR=\"#ffffff\" TEXT=\"#000000\"";

$messagespec = "";

$NewCode = "<EM><FONT COLOR=\"#990000\">NEW:</FONT></EM> ";

#$HeadLinesFile = "";
#$HeaderFile = "/usr/userid/board/header.txt";
#$FooterFile = "/usr/userid/board/footer.txt";

$MessageHeaderFile = "";
$MessageFooterFile = "";

$UseFrames = "";
$BBSFrame = "_parent";
$WelcomePage = "";

$TopNPosters = 10;

$Admin_Link_Name = "";
$Admin_Link_URL = "";

$SepPostForm = 0;

$DefaultType = "";
$DefaultTime = "";

$boardname = "WebBBS Discussion Board";
$printboardname = 1;

$DateConfig = "";
$IndexEntryLines = 2;

$InputColumns = 80;
$InputRows = 15;

$HourOffset = 0;

$ArchiveOnly = 0;
$AllowHTML = 0;
$SingleLineBreaks = 0;

$AutoQuote = 0;
$AutoQuoteChar = ":";

$AutoHotlink = 0;

$DisplayIPs = 0;
$DisplayViews = 0;

$UseCookies = 1;
require "/cgi-local/cookie.lib";

$Max_Days = 0;
$Max_Messages = 0;

$ArchiveDir = "";

## (3) Define your visitors' capabilities:

$MaxMessageSize = 50;

$MaxInputLength = 50;

$LockRemoteUser = 0;

$AllowUserDeletion = 0;
$AllowEmailNotices = 0;
$AllowPreview = 1;

$AllowURLs = 0;
$AllowPics = 0;

$SaveLinkInfo = 0;

$AllowUserPrefs = 1;
$AllowResponses = 1;

$NaughtyWords = "";
$CensorPosts = 0;

$BannedIPs = "";

## (4) Define your e-mail notification features:

$mailprog = '';
$WEB_SERVER = "";
$SMTP_SERVER = "";

$admin_name = "Administrator";
$maillist_address = "gobbly/@aol.com";
$notification_address = "";
$email_list = "";
$private_list = 0;

$HeaderOnly = 0;

# use Socket;

&WebBBS;

## (5) If necessary, set up the WebAdverts configuration subroutine

sub insertadvert {
	require "/full/path/to/ads_display.pl";
	$adverts_dir = "/full/path/to/ads";
	$display_cgi = "http://foo.com/ads/ads.pl";
	$advertzone = $_[0];
	$ADVUseLocking = 1;
	$ADVLogIP = 0;
	$DefaultBanner = "";
	$ADVNoPrint = 1;
	$ADVQuery = "";
	&ADVsetup;
}



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

Date: Fri, 10 Sep 1999 10:17:01 +0100
From: "Produktiv" <pj@produktiv.com>
Subject: Re: Printing characters in reverse-video to screen
Message-Id: <37d8c916.0@dns.amsinc.com>


Kushagra Vaid <kvaid@mipos2.intel.com> wrote in message
news:37D88653.1B82B99A@mipos2.intel.com...
>
> Is it possible to use a sequence of escape characters (or some other
method) in
> Perl, to print out
> a string of characters in reverse-video?

You don't say if this is on Unix or NT.
On Unix, one way to do it is to use the tput command, providing your system
uses TERMINFO. There may be other (better?) ways.

Here is an example:
    #!/usr/bin/perl -w

    my $bold=`tput smso`;    # Set reverse video
    my $norm=`tput rmso`;    # reset back to normal

    print $bold."Hello World".$norm." have a nice day!\n";

>
> -KV
>

/Paul Jardine

- Democracy is the mistaken belief that more than half the people are right,
more than half of the time.
   Leadership is managing to convince more than half of the people that you
are right more than half of the time.




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

Date: Friday, 10 Sep 1999 22:29:15 -0600
From: nobody@nowhere33.yet
Subject: Sell a product which costs nothing to produce!
Message-Id: <10099922.2915@nowhere33.yet>

***Fantastic New Opportunity***
****Dont Miss Out on this one****
**Have Your Downline Built for You**
NNTP-Posting-Host: 203.101.58.30
Lines: 12
Path: diablo.net.ohio-state.edu!cyclone.columbus.rr.com!news-out.cwix.com!newsfeed.cwix.com!logbridge.uoregon.edu!uunet!sea.uu.net!dfw.uu.net!lax.uu.net!pink.one.net.au!nowhere33.yet

Start your own e-mail business today!
Starting your own e-mail business will enable you to take advantage of the following benefits: 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1. Top part-time owners have earned $5,000+ in one month
2. Top full-time owners have earned $10,000+ in one month
3. All customers pay you in cash!!!
4. You will sell a product which costs nothing to produce! 
5. Your only overhead is your time!
6. Your start up costs are less than $25
7. You have more than 40 million potential customers

For additional information please E-mail me at 50k@myreply.com


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

Date: Fri, 10 Sep 1999 06:04:10 -0400
From: "Harlan Carvey, CISSP" <carvdawg@patriot.net>
Subject: Re: Services in Perl
Message-Id: <37D8D79A.264E1B82@patriot.net>


Win32::Lanman offers much greater control over Services...you can even use it to

create your own Services.

Carv

Aaron Lister wrote:

> Anyone know how to create a service on a winnt platform in
> perl?
>
> * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
> The fastest and easiest way to search and participate in Usenet - Free!



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

Date: 10 Sep 1999 11:06:59 GMT
From: "Kommunedata" <xxx@kmd.dk>
Subject: Re: Services in Perl
Message-Id: <01befb7c$9cfb6470$7efa14ac@h-11434>

If you install the NT ResKit you will have a file called
srvany.wri and srvany.exe.

Here is the file srvany.wri that describes how to run eg a perl program as
a service


This file describes the SRVANY.EXE utility. This utility allows running
Windows NT™ applications as services. The benefits include:
- allow apps to survive logoff/logon sequences, hence saving the overhead
of re-starting them for each new user
- allow server apps to come-up and service requests even when no user is
logged-on
- allow apps to run and perform a task in a specific logon account,
different from the currently logged-on user 

NOTICES:
1. Some applications may terminate upon logoff, even though they were
started as a service, if they don't ignore the WM_ENDSESSION message (or
CTRL_LOGOFF_EVENT). See "Programming Considerations" below for more
details.
2. When using SRVANY.EXE with Presentation Manager® applications, special
configuration instructions apply - please read the README.WRI file shipped
on Disk#1 of the Windows NT™ Add-On Subsystem for Presentation Manager®,
version 3.51 (a Microsoft add-on product which allows running 16-bit
Presentation Manager® 1.x applications in addition to the OS/2
character-mode applications supported by the Windows NT™ OS/2 Subsystem).


Installation:

-> Copy SRVANY.EXE to your system and install it as a Windows NT™ service,
for example:
	INSTSRV MyService c:\tools\srvany.exe
-> configure via the Services applet ("Startup..." dialog) of the Control
Panel as manual or automatic, as appropriate.
-> set via the Services applet ("Startup..." dialog) of the Control Panel
the account for the service. If you need access to the screen & keyboard,
you must choose the LocalSystem account and click the "Allow Service to
Interact with Desktop", otherwise choose any account and specify the
correct logon password. Note that the LocalSystem account doesn't have
network access.


Specifying the application to start & its parameters:

Run the Registry Editor (REGEDT32.EXE):
-> under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService:
create a 'Parameters' key
-> under the above key, create an 'Application' value of type REG_SZ and
specify there the full path of your app executable (including the
extension). For example:
 	Application: REG_SZ: D:\TOOLS\VI.EXE
 -> OPTIONAL: under the above key, create an 'AppParameters' value of type
REG_SZ and specify the parameters for your app. For Example:
	AppParameters: REG_SZ: C:\TMP\FOO
-> OPTIONAL: under the above key, create an 'AppDirectory' value of type
REG_SZ and specify the current directory to use for the app, eg:
	AppDirectory: REG_SZ: C:\TMP

The case of all above strings is not important.

There is also another way to specify the service parameters, via the
Control Panel. Note that this method applies only to the case where the
service is configured to be started manually (i.e. not when it is started
automatically with the system):
2. Via the Control Panel, Services applet:
-> type in the Startup Parameters box the full command-line, incl. the app
name. Example:
	D:\\BINP\\B.EXE C:\\TMP\\FOO
    (note the '\\' is needed to result in '\')
-> if you want to specify the current working directory, use the '/D'
switch before the app name, eg:
	/D C:\\TMP D:\\TOOLS\\VI.EXE C:\\TMP\\FOO

NOTICE: Specifying the target application via the Control Panel is usually
inconvenient because the parameters have to be typed every time the service
is started. However, this may be convenient in cases where the target
application is different every time the service is started.


Starting & stopping the service:

Start:
If the service is configured as 'Automatic', the user doesn't need to start
it explicitely: it is started automatically every time when the system is
re-booted.
For 'manual' services, the user may start services in several ways:
    - from the Services applet of the Control Panel
	or
    - using the SC.EXE utility, eg: SC start MyService
	or
    - NET START MyService

Stop:
When you stop the service, it will terminate the application it had
started. The way to stop the service is (as described above for starting):
    - from the Services applet of the Control Panel
	or
    - using the SC.EXE utility, eg: SC stop MyService
	or
    - NET STOP MyService

WARNING:
When the service is stopped, it terminates the application via the WIN32
TerminateProcess() API: this is a drastic way to end an application. For
example, it would not allow the application to prompt the user to save
changes. Therefore, it is recommended to close the application BEFORE
stopping the service.


De-installation:

If you want to prevent an instance of the SRVANY utility from running until
further notice, you should configure it via the Services applet
("Startup..." dialog) of the Control Panel as 'Disabled' (rather than
'manual' or 'automatic').

If you want to remove an instance of the SRVANY utility permanently:
-> If the service is running, stop it (see "Starting and stopping the
service" above)
-> Run:
	INSTSRV MyService remove

NOTICE: this procedure removes only one specific instance of SRVANY.
Therefore, it is possible that SRVANY.EXE is still being used to start
other applications as services.


Programming Considerations:

For WIN32 graphical applications: when the currently logged-in user is
logging-off, all WIN32 top-level windows receive WM_QUERYENDSESSION and
WM_ENDSESSION messages. Some WIN32 applications choose to terminate upon
receipt of such messages. In order for your WIN32 application to survive
logoff, it must not do that: instead, your windows procedure should call
the default windows procedure on these messages.

For WIN32 Console (i.e. character-mode) applications: when the currently
logged-in user is logging-off, all Console applications receive a
CTRL_LOGOFF_EVENT event from the Console. 
If your Console application has registered a Console event handler (via
SetConsoleCtrlHandler), it must ignore CTRL_LOGOFF_EVENT in order  to
survive the logoff.


Comments/limitations:

-> You may install SRVANY.EXE several times with different registry
parameters (i.e. running different target applications) - just use a
distinct service name for each instance (e.g. MyService1, MyService2 etc.)

-> If SRVANY.EXE fails to start your application, try specifying as current
directory the directory where your application is installed (see
'AppDirectory' registry key or '/D' above). SRVANY.EXE may be running under
an account different than the currently logged-on user therefore
environment variables may be set differently: as a result, for example, the
system might have been unable to find a DLL required for your application
and running it from the application's directory might help.

-> Due to a restriction enforced by Windows NT™ on services, the
application can either be interactive (have a Console, read keyboard input
etc.) or have network access (not both at the same time).
This limitation is less problematic than it would appear at first glance.
Here is why:
If you know which servers your interactive service application needs to
access, it is possible to configure these servers (or selected shares on
them) to allow your service (running under the LocalSystem account) to
access these servers.
a.To allow LocalSystem services on any machine in the domain to access a
specific share on a server, use the Registry Editor to add the name of that
share to:	
	HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameter
s\NullSessionShares
If named pipes on that server also need to be accessed by LocalSystem
services, add them to:
	HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameter
s\NullSessionPipes
b.To allow ALL shares & pipes on the server to be accessed by LocalSystem
services, add a value:
	HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameter
s\RestrictNullSessAccess, type DWORD, set to value 0
WARNING: method b) effectively allows everyone in the domain to access that
server - make sure this is acceptable for you.



Aaron Lister <alister2NOfnSPAM@csc.co.nz> wrote in article
<1415c574.0de9d1ae@usw-ex0102-013.remarq.com>...
> Anyone know how to create a service on a winnt platform in 
> perl?
> 
> * Sent from RemarQ http://www.remarq.com The Internet's Discussion
Network *
> The fastest and easiest way to search and participate in Usenet - Free!
> 
> 


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

Date: Fri, 10 Sep 1999 06:02:42 -0400
From: "Harlan Carvey, CISSP" <carvdawg@patriot.net>
Subject: Re: Win32::ODBC help
Message-Id: <37D8D742.13217CA8@patriot.net>

> > > >       $stmt = "INSERT INTO ITEST1 (HostID,RegKey,Value,Data)".
> > > >                 "VALUES ('$server','$rkey','$valkey','$value')";
> > >
> > > There is an SQL syntax error in the contents of $stmt
> >
> > Where?
>
> Try printing out $stmt to see what it actually looks like.  Hint: white
> space!

I've tried that...I've tried using perl -d test1.pl...

What I don't understand is why the sub that simply INSERTs into a database
table works fine, but the sub that reads from one table and inserts into
another doesn't.

Yes, and I caught the thing about the whitespace at the end of the first
line..so I added a
space and guess what?  Nothing happened.  I'm not getting an error back
from the
Sql($stmt) call...but nothings being inserted into the database.

carv




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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu. 

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 757
*************************************


home help back first fref pref prev next nref lref last post