Re: help with my perl script
On 3/25/07, Reidy, Ron [EMAIL PROTECTED] wrote: This tells me there is something not set in your environment. Have you tried setting the environment like I specified? Here's a handy method for getting the environment correct in a script (DBI or otherwise) to run from cron when all else seems to fail. Most here probably know that cron does not setup the environment when it runs a job. That is left up to you. When a script is run withe 'at' utility however, entire environment is dumped into a file to be used by 'at'. Setup your job to run in the future with 'at', then you can use the contents of the 'at' script to build a script for cron. I've used this a couple times when scripts failed to run in cron, though I seemed to have included every possible env variable. example - run ls 1 hour from now: 9:12-jkstill-2 at now + 1 hour at ls -l at EOT job 2 at 2007-04-11 10:13 [ /home/jkstill/tmp ] 9:13-jkstill-2 Now as root, navigate to the /var/spool/at directory. [root /]# cd /var/spool/at [root at]# ls -ltr total 16 drwx-- 2 daemon daemon 4096 Dec 28 10:26 spool -rwx-- 1 jkstill dba3685 Apr 11 09:13 a2012b26c9 [root at]# The file a2012b26c9 has all of my environment in it, followed by the command to run. There will be number of things that can obviously be removed from the file. eg. [root at]# cat a2012b26c9 #!/bin/sh # atrun uid=501 gid=300 # mail jkstill 0 umask 27 PATH=/home/jkstill/bin:/bin:/:/u01/app/perl/bin:/usr/bin:/usr/local/sbin:/usr/lib:/etc:/usr/local/bin:/home/jkstill/bin:/bin:/:/u01/app/perl/bin:/usr/bin:/usr/local/sbin:/usr/lib:/etc:/usr/sbin:/home/jkstill/perl:/usr/X11R6/bin:/u01/app/oracle/product/9.2.0/9ir2dev/bin; export PATH ... ${SHELL:-/bin/sh} `(dd if=/dev/urandom count=200 bs=1 2/dev/null|LC_ALL=C tr -d -c '[:alnum:]')` ls -l HTH -- Jared Still Certifiable Oracle DBA and Part Time Perl Evangelist
RE: help with my perl script
This tells me there is something not set in your environment. Have you tried setting the environment like I specified? rr From: joe bayer [mailto:[EMAIL PROTECTED] Sent: Friday, March 23, 2007 7:28 PM To: Reidy, Ron; RaviChandra Chelikam; dbi-users@perl.org Subject: RE: help with my perl script Yes, DB is running. If I run ./test.sh, there is no problem. The problem comes only when I put it in cron. Reidy, Ron [EMAIL PROTECTED] wrote: Then there is something wrong with your environment. Have you tried using oraenv to set you environment vs. setting the %ENV hash? In cron, it would look like this: (export ORAENV_ASK=NO export ORACLE_SID=test . oraenv /path/to/rman/script) There are other environment variables that are set in oraenv. Another question I have to ask - is the DB running? -- Ron Reidy Lead DBA Array BioPharma, Inc. From: joe bayer [mailto:[EMAIL PROTECTED] Sent: Friday, March 23, 2007 4:25 PM To: Reidy, Ron; RaviChandra Chelikam; dbi-users@perl.org Subject: RE: help with my perl script Thanks for your prompt response. I tried $ENV{ORACLE_SID}=$ORACLE_SID or $ENV{ORACLE_SID}=test It did not work. Reidy, Ron [EMAIL PROTECTED] wrote: See below ... From: joe bayer [mailto:[EMAIL PROTECTED] Sent: Friday, March 23, 2007 3:33 PM To: Reidy, Ron; RaviChandra Chelikam; dbi-users@perl.org Subject: help with my perl script Dear group, I know it is not DBI related problem, but it is hard to find some one who knows perl, shell and Oracle. I am trying to write a RMAN script, == #!/usr/bin/perl my $ORACLE_HOME = /opt/oracle/product_10g/test/10.2; $ENV{ORACLE_HOME}=$ORACLE_HOME; my $ORACLE_SID=test; $ENV{ORACLE_SID}=test; # what is this? Shouldn't this read $ENV{ORACLE_SID}=$ORACLE_SID or $ENV{ORACLE_SID}=test my $backup_log = /backup/backup_log.log; open RMAN, | /opt/oracle/product_10g/eratest/10.2/bin/rman target=sys/temp log=$backup_log or die Can't pipe to $!; print RMAN exit\n; close RMAN; == It works in command line, but when I put it into crontab job, I always get === connected to target database (not started) RMAN === The script does not recognize the sid, what can I do to fix it? Thanks very much for your help. No need to miss a message. Get email on-the-go http://us.rd.yahoo.com/evt=43910/*http:/mobile.yahoo.com/mail%0d%0a with Yahoo! Mail for Mobile. Get started. http://us.rd.yahoo.com/evt=43910/*http:/mobile.yahoo.com/mail%0d%0a size=2 width=100% align=center This electronic message transmission is a PRIVATE communication which contains information which may be confidential or privileged. The information is intended to be for the use of the individual or entity named above. If you are not the intended recipient, please be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. Please notify the sender of the delivery error by replying to this message, or notify us by telephone (877-633-2436, ext. 0), and then delete it from your system. No need to miss a message. Get email on-the-go http://us.rd.yahoo.com/evt=43910/*http:/mobile.yahoo.com/mail%0d%0a with Yahoo! Mail for Mobile. Get started. http://us.rd.yahoo.com/evt=43910/*http:/mobile.yahoo.com/mail%0d%0a TV dinner still cooling? Check out Tonight's Picks http://us.rd.yahoo.com/evt=49979/*http:/tv.yahoo.com/ on Yahoo! TV.
RE: help with my perl script
Because you pointed your ORACLE_HOME variable at this new install and then issued startup nomount in your script, it just naturally follows you would have a second instance up and running. So, obviously, perl is working and so is your script. So, let's start over. You are trying to mimic an interactive session with RMAN. I assume you are a DBA and you have read the Oracle backup and recovery and RMAN documents. If you are not familiar with these, you should read and understand them. Next, I suggest the following: 1. Open a session on your server and Set your environment using oraenv 2. Start RMAN like you would in your script. 3. Issue the commands you are trying to get your script to the RMAN process you are running. Note the results. Do not set your environment using the %ENV hash - use oraenv. I cannot stress this enough. I know one of the mantras of Perl is TMTOWTDI, but this does not hold true for the use of oraenv. I have been a DBA for almost 10 years and have been working with Perl since version 4 and this is by far the easiest way to set up your environment and to keep things running. Good luck. rr From: joe bayer [mailto:[EMAIL PROTECTED] Sent: Friday, March 23, 2007 9:13 PM To: Reidy, Ron; RaviChandra Chelikam; dbi-users@perl.org Subject: RE: help with my perl script I I just installed the ORACLE 10.2.0.3 to another home, and re-run the script, this time, even perl itself stopped running. === The script is like this: #!/usr/bin/perl my $ORACLE_HOME = /opt/oracle/product_10g_2; $ENV{ORACLE_HOME}=$ORACLE_HOME; my $ORACLE_SID=test; $ENV{ORACLE_SID}=$ORACLE_SID; my $backup_log = backup_log.log; open RMAN, | /opt/oracle/product_10g_2/bin/rman target=sys/temp or die Can't pipe to $!; print RMAN startup nomount\n; print RMAN exit\n; close RMAN; = [EMAIL PROTECTED] dba]$ ps -eaf|grep pmon ora92 8178 1 0 22:31 ?00:00:00 ora_pmon_test ora9210212 1 0 23:04 ?00:00:00 ora_pmon_test The SID did passed, but somehow this test is different from that test, how can that be possible? Thanks for your help. Reidy, Ron [EMAIL PROTECTED] wrote: Then there is something wrong with your environment. Have you tried using oraenv to set you environment vs. setting the %ENV hash? In cron, it would look like this: (export ORAENV_ASK=NO export ORACLE_SID=test . oraenv /path/to/rman/script) There are other environment variables that are set in oraenv. Another question I have to ask - is the DB running? -- Ron Reidy Lead DBA Array BioPharma, Inc. From: joe bayer [mailto:[EMAIL PROTECTED] Sent: Friday, March 23, 2007 4:25 PM To: Reidy, Ron; RaviChandra Chelikam; dbi-users@perl.org Subject: RE: help with my perl script Thanks for your prompt response. I tried $ENV{ORACLE_SID}=$ORACLE_SID or $ENV{ORACLE_SID}=test It did not work. Reidy, Ron [EMAIL PROTECTED] wrote: See below ... From: joe bayer [mailto:[EMAIL PROTECTED] Sent: Friday, March 23, 2007 3:33 PM To: Reidy, Ron; RaviChandra Chelikam; dbi-users@perl.org Subject: help with my perl script Dear group, I know it is not DBI related problem, but it is hard to find some one who knows perl, shell and Oracle. I am trying to write a RMAN script, == #!/usr/bin/perl my $ORACLE_HOME = /opt/oracle/product_10g/test/10.2; $ENV{ORACLE_HOME}=$ORACLE_HOME; my $ORACLE_SID=test; $ENV{ORACLE_SID}=test; # what is this? Shouldn't this read $ENV{ORACLE_SID}=$ORACLE_SID or $ENV{ORACLE_SID}=test my $backup_log = /backup/backup_log.log; open RMAN, | /opt/oracle/product_10g/eratest/10.2/bin/rman target=sys/temp log=$backup_log or die Can't pipe to $!; print RMAN exit\n; close RMAN; == It works in command line, but when I put it into crontab job, I always get === connected to target database (not started) RMAN === The script does not recognize the sid, what can I do to fix it? Thanks very much for your help. No need to miss a message. Get email on-the-go http://us.rd.yahoo.com/evt=43910/*http:/mobile.yahoo.com/mail%0d%0a with Yahoo! Mail for Mobile. Get started. http://us.rd.yahoo.com/evt=43910/*http:/mobile.yahoo.com/mail%0d%0a size=2 width=100% align=center This electronic message transmission is a PRIVATE communication which contains information which may be confidential or privileged. The information is intended to be for the use of the individual or entity named above. If you are not the intended recipient, please be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. Please notify the sender of the delivery error by replying to this message, or notify us by telephone (877-633-2436, ext. 0), and then delete it from your
Re: help with my perl script
Joe et al Sounds like a permissions problem Which user was used to install 10.2.0.3? What happens when you use that same user ro install and run perl scripts? M- --- This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. --- Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire. - Original Message - From: joe bayer [EMAIL PROTECTED] To: Reidy, Ron [EMAIL PROTECTED]; RaviChandra Chelikam [EMAIL PROTECTED]; dbi-users@perl.org Sent: Friday, March 23, 2007 11:12 PM Subject: RE: help with my perl script I I just installed the ORACLE 10.2.0.3 to another home, and re-run the script, this time, even perl itself stopped running. === The script is like this: #!/usr/bin/perl my $ORACLE_HOME = /opt/oracle/product_10g_2; $ENV{ORACLE_HOME}=$ORACLE_HOME; my $ORACLE_SID=test; $ENV{ORACLE_SID}=$ORACLE_SID; my $backup_log = backup_log.log; open RMAN, | /opt/oracle/product_10g_2/bin/rman target=sys/temp or die Can't pipe to $!; print RMAN startup nomount\n; print RMAN exit\n; close RMAN; = [EMAIL PROTECTED] dba]$ ps -eaf|grep pmon ora92 8178 1 0 22:31 ?00:00:00 ora_pmon_test ora9210212 1 0 23:04 ?00:00:00 ora_pmon_test The SID did passed, but somehow this test is different from that test, how can that be possible? Thanks for your help. Reidy, Ron [EMAIL PROTECTED] wrote: v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} st1\:*{behavior:url(#default#ieooui) } Then there is something wrong with your environment. Have you tried using oraenv to set you environment vs. setting the %ENV hash? In cron, it would look like this: (export ORAENV_ASK=NO export ORACLE_SID=test . oraenv /path/to/rman/script) There are other environment variables that are set in oraenv. Another question I have to ask - is the DB running? -- Ron Reidy Lead DBA Array BioPharma, Inc. - From: joe bayer [mailto:[EMAIL PROTECTED] Sent: Friday, March 23, 2007 4:25 PM To: Reidy, Ron; RaviChandra Chelikam; dbi-users@perl.org Subject: RE: help with my perl script Thanks for your prompt response. I tried $ENV{ORACLE_SID}=$ORACLE_SID or $ENV{ORACLE_SID}=test It did not work. Reidy, Ron [EMAIL PROTECTED] wrote: See below . - From: joe bayer [mailto:[EMAIL PROTECTED] Sent: Friday, March 23, 2007 3:33 PM To: Reidy, Ron; RaviChandra Chelikam; dbi-users@perl.org Subject: help with my perl script Dear group, I know it is not DBI related problem, but it is hard to find some one who knows perl, shell and Oracle. I am trying to write a RMAN script, == #!/usr/bin/perl my $ORACLE_HOME = /opt/oracle/product_10g/test/10.2; $ENV{ORACLE_HOME}=$ORACLE_HOME; my $ORACLE_SID=test; $ENV{ORACLE_SID}=test; # what is this? Shouldn't this read $ENV{ORACLE_SID}=$ORACLE_SID or $ENV{ORACLE_SID}=test my $backup_log = /backup/backup_log.log; open RMAN, | /opt/oracle/product_10g/eratest/10.2/bin/rman target=sys/temp log=$backup_log or die Can't pipe to $!; print RMAN exit\n; close RMAN; == It works in command line, but when I put it into crontab job, I always get === connected to target database (not started) RMAN === The script does not recognize the sid, what can I do to fix it? Thanks very much for your help. - No need to miss a message. Get email on-the-go with Yahoo! Mail for Mobile. Get started. - size=2 width=100% align=center This electronic message transmission is a PRIVATE communication which contains information which may be confidential or privileged
help with my perl script
Dear group, I know it is not DBI related problem, but it is hard to find some one who knows perl, shell and Oracle. I am trying to write a RMAN script, == #!/usr/bin/perl my $ORACLE_HOME = /opt/oracle/product_10g/test/10.2; $ENV{ORACLE_HOME}=$ORACLE_HOME; my $ORACLE_SID=test; $ENV{ORACLE_SID}=test; my $backup_log = /backup/backup_log.log; open RMAN, | /opt/oracle/product_10g/eratest/10.2/bin/rman target=sys/temp log=$backup_log or die Can't pipe to $!; print RMAN exit\n; close RMAN; == It works in command line, but when I put it into crontab job, I always get === connected to target database (not started) RMAN === The script does not recognize the sid, what can I do to fix it? Thanks very much for your help. - No need to miss a message. Get email on-the-go with Yahoo! Mail for Mobile. Get started.
RE: help with my perl script
See below ... From: joe bayer [mailto:[EMAIL PROTECTED] Sent: Friday, March 23, 2007 3:33 PM To: Reidy, Ron; RaviChandra Chelikam; dbi-users@perl.org Subject: help with my perl script Dear group, I know it is not DBI related problem, but it is hard to find some one who knows perl, shell and Oracle. I am trying to write a RMAN script, == #!/usr/bin/perl my $ORACLE_HOME = /opt/oracle/product_10g/test/10.2; $ENV{ORACLE_HOME}=$ORACLE_HOME; my $ORACLE_SID=test; $ENV{ORACLE_SID}=test; # what is this? Shouldn't this read $ENV{ORACLE_SID}=$ORACLE_SID or $ENV{ORACLE_SID}=test my $backup_log = /backup/backup_log.log; open RMAN, | /opt/oracle/product_10g/eratest/10.2/bin/rman target=sys/temp log=$backup_log or die Can't pipe to $!; print RMAN exit\n; close RMAN; == It works in command line, but when I put it into crontab job, I always get === connected to target database (not started) RMAN === The script does not recognize the sid, what can I do to fix it? Thanks very much for your help. No need to miss a message. Get email on-the-go http://us.rd.yahoo.com/evt=43910/*http:/mobile.yahoo.com/mail%0d%0a with Yahoo! Mail for Mobile. Get started. http://us.rd.yahoo.com/evt=43910/*http:/mobile.yahoo.com/mail%0d%0a This electronic message transmission is a PRIVATE communication which contains information which may be confidential or privileged. The information is intended to be for the use of the individual or entity named above. If you are not the intended recipient, please be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. Please notify the sender of the delivery error by replying to this message, or notify us by telephone (877-633-2436, ext. 0), and then delete it from your system.
Re: help with my perl script
Le vendredi 23 mars 2007 à 14:33 -0700, joe bayer a écrit : snip my $ORACLE_SID=test; $ENV{ORACLE_SID}=test; Could this be your culprit ? Try with either $ENV{ORACLE_SID}=test; or $ENV{ORACLE_SID}=$ORACLE_SID; -- Olivier
RE: help with my perl script
I I just installed the ORACLE 10.2.0.3 to another home, and re-run the script, this time, even perl itself stopped running. === The script is like this: #!/usr/bin/perl my $ORACLE_HOME = /opt/oracle/product_10g_2; $ENV{ORACLE_HOME}=$ORACLE_HOME; my $ORACLE_SID=test; $ENV{ORACLE_SID}=$ORACLE_SID; my $backup_log = backup_log.log; open RMAN, | /opt/oracle/product_10g_2/bin/rman target=sys/temp or die Can't pipe to $!; print RMAN startup nomount\n; print RMAN exit\n; close RMAN; = [EMAIL PROTECTED] dba]$ ps -eaf|grep pmon ora92 8178 1 0 22:31 ?00:00:00 ora_pmon_test ora9210212 1 0 23:04 ?00:00:00 ora_pmon_test The SID did passed, but somehow this test is different from that test, how can that be possible? Thanks for your help. Reidy, Ron [EMAIL PROTECTED] wrote: v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} st1\:*{behavior:url(#default#ieooui) } Then there is something wrong with your environment. Have you tried using oraenv to set you environment vs. setting the %ENV hash? In cron, it would look like this: (export ORAENV_ASK=NO export ORACLE_SID=test . oraenv /path/to/rman/script) There are other environment variables that are set in oraenv. Another question I have to ask is the DB running? -- Ron Reidy Lead DBA Array BioPharma, Inc. - From: joe bayer [mailto:[EMAIL PROTECTED] Sent: Friday, March 23, 2007 4:25 PM To: Reidy, Ron; RaviChandra Chelikam; dbi-users@perl.org Subject: RE: help with my perl script Thanks for your prompt response. I tried $ENV{ORACLE_SID}=$ORACLE_SID or $ENV{ORACLE_SID}=test It did not work. Reidy, Ron [EMAIL PROTECTED] wrote: See below - From: joe bayer [mailto:[EMAIL PROTECTED] Sent: Friday, March 23, 2007 3:33 PM To: Reidy, Ron; RaviChandra Chelikam; dbi-users@perl.org Subject: help with my perl script Dear group, I know it is not DBI related problem, but it is hard to find some one who knows perl, shell and Oracle. I am trying to write a RMAN script, == #!/usr/bin/perl my $ORACLE_HOME = /opt/oracle/product_10g/test/10.2; $ENV{ORACLE_HOME}=$ORACLE_HOME; my $ORACLE_SID=test; $ENV{ORACLE_SID}=test; # what is this? Shouldnt this read $ENV{ORACLE_SID}=$ORACLE_SID or $ENV{ORACLE_SID}=test my $backup_log = /backup/backup_log.log; open RMAN, | /opt/oracle/product_10g/eratest/10.2/bin/rman target=sys/temp log=$backup_log or die Can't pipe to $!; print RMAN exit\n; close RMAN; == It works in command line, but when I put it into crontab job, I always get === connected to target database (not started) RMAN === The script does not recognize the sid, what can I do to fix it? Thanks very much for your help. - No need to miss a message. Get email on-the-go with Yahoo! Mail for Mobile. Get started. - size=2 width=100% align=center This electronic message transmission is a PRIVATE communication which contains information which may be confidential or privileged. The information is intended to be for the use of the individual or entity named above. If you are not the intended recipient, please be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. Please notify the sender of the delivery error by replying to this message, or notify us by telephone (877-633-2436, ext. 0), and then delete it from your system. - No need to miss a message. Get email on-the-go with Yahoo! Mail for Mobile. Get started. - Be a PS3 game guru. Get your game face on with the latest PS3 news and previews at Yahoo! Games.
Help with my perl script
Group, I am trying to write a load testing script. The script goes like this: ++ my $j = 0; while ($j 300) { $dbh[$j] = DBI-connect ( dbi:Oracle:$instance[$i], $username[$i], $passwd[$i], { PrintError = 1, RaiseError = 1, AutoCommit = 1 } ) || die Database Connection not made $DBI::errstr ;# Create a Database #do some random, endless select statement here. $j++; } ++ What I want is 300 session do the select statement simultaneously. But this script will do one session after another. Do I REALLY have to start 300 perl script in order to this testing, or there is some way in perl that one script can start up 300 session and do their invidual select simultaneously? Thanks for your help. Joe - All-new Yahoo! Mail - Fire up a more powerful email and get things done faster.
Re: Help with my perl script
joe bayer wrote: Group, I am trying to write a load testing script. The script goes like this: ++ my $j = 0; while ($j 300) { $dbh[$j] = DBI-connect ( dbi:Oracle:$instance[$i], $username[$i], $passwd[$i], { PrintError = 1, RaiseError = 1, AutoCommit = 1 } ) || die Database Connection not made $DBI::errstr ;# Create a Database #do some random, endless select statement here. $j++; } ++ What I want is 300 session do the select statement simultaneously. But this script will do one session after another. Do I REALLY have to start 300 perl script in order to this testing, or there is some way in perl that one script can start up 300 session and do their invidual select simultaneously? Check out Parallel::ForkManager. Thanks for your help. Joe - All-new Yahoo! Mail - Fire up a more powerful email and get things done faster. -- Stephen Carville [EMAIL PROTECTED] Unix and Network Admin Nationwide Totalflood 6033 W. Century Blvd Los Angeles, CA 90045 310-342-3602
Re: Help with my perl script
On 8/23/06, Stephen Carville [EMAIL PROTECTED] wrote: joe bayer wrote: Group, I am trying to write a load testing script. The script goes like this: ++ my $j = 0; while ($j 300) { $dbh[$j] = DBI-connect ( dbi:Oracle:$instance[$i], $username[$i], $passwd[$i], { PrintError = 1, RaiseError = 1, AutoCommit = 1 } ) || die Database Connection not made $DBI::errstr ;# Create a Database #do some random, endless select statement here. $j++; } ++ What I want is 300 session do the select statement simultaneously. But this script will do one session after another. Do I REALLY have to start 300 perl script in order to this testing, or there is some way in perl that one script can start up 300 session and do their invidual select simultaneously? Check out Parallel::ForkManager. Thanks for your help. Joe - All-new Yahoo! Mail - Fire up a more powerful email and get things done faster. Hi Stephen, Unless I'm missing something (I'm no expert in this arena) It seems like a script will ecxecute one stmt at a time anyway- so how about cranking up 300 separate Perl scripts that synchoronize (ie, soak up all available system resources simultaneously) with a named semaphore? (Win) $sem = Win32::Semaphore-new($initial,$maximum,$name); (Unix) $sem = new IPC::Semaphore(IPC_PRIVATE, 10, S_IRWXU | IPC_CREAT); I would envision you building a 300-line script to start up each individual DB connect, and a single Perl script to lower the flag - causing the 300 perl scripts to pounce. It seems like this is a much better test anyway- because I very much doubt as *single* perl script will have 300 separate DB connections... but then again... I don't know what your environment needs. HTH KC
RE: Help with my perl script
I believe you *are* missing something. You're going to have to understand how processes and forking work in Unix. The fork() call invokes a new process. In effect it is a new script on its own. Stephen's Parallel::ForkManager is just syntactic sugaring around the same thing. Semaphores have no meaning unless you have separate tasks running. A process is a kind of task. You do not need the semaphore for your test as I understand it. The operating system's scheduler is going to allocate time slices to each process as it sees fit. Each forked child process is a real process of its own, and each will open a connection to the database, independent of the other child processes. The time statements are actually executed relative to one another is essentially random, which is I believe what you want. I suggest you read the description of fork() in the perlfunc man page *very* carefully, as it does a lot more than you may have realised the first time through. Also you should try reading up on Unix process semantics. Again, I recommend simply using fork(), in a loop. -Will -Original Message- From: Kevin Carothers [mailto:[EMAIL PROTECTED] Sent: Wednesday 23 August 2006 16:48 To: Stephen Carville Cc: dbi-users@perl.org; joe bayer Subject: Re: Help with my perl script On 8/23/06, Stephen Carville [EMAIL PROTECTED] wrote: joe bayer wrote: Group, I am trying to write a load testing script. The script goes like this: ++ my $j = 0; while ($j 300) { $dbh[$j] = DBI-connect ( dbi:Oracle:$instance[$i], $username[$i], $passwd[$i], { PrintError = 1, RaiseError = 1, AutoCommit = 1 } ) || die Database Connection not made $DBI::errstr ;# Create a Database #do some random, endless select statement here. $j++; } ++ What I want is 300 session do the select statement simultaneously. But this script will do one session after another. Do I REALLY have to start 300 perl script in order to this testing, or there is some way in perl that one script can start up 300 session and do their invidual select simultaneously? Check out Parallel::ForkManager. Thanks for your help. Joe - All-new Yahoo! Mail - Fire up a more powerful email and get things done faster. Hi Stephen, Unless I'm missing something (I'm no expert in this arena) It seems like a script will ecxecute one stmt at a time anyway- so how about cranking up 300 separate Perl scripts that synchoronize (ie, soak up all available system resources simultaneously) with a named semaphore? (Win) $sem = Win32::Semaphore-new($initial,$maximum,$name); (Unix) $sem = new IPC::Semaphore(IPC_PRIVATE, 10, S_IRWXU | IPC_CREAT); I would envision you building a 300-line script to start up each individual DB connect, and a single Perl script to lower the flag - causing the 300 perl scripts to pounce. It seems like this is a much better test anyway- because I very much doubt as *single* perl script will have 300 separate DB connections... but then again... I don't know what your environment needs. HTH KC - - - - - Appended by Scientific Atlanta, a Cisco company - - - - - This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.
Re: Help with my perl script
On 8/23/06, Rutherdale, Will [EMAIL PROTECTED] wrote: Again, I recommend simply using fork(), in a loop. a rabbit doesn't need a loop... $start_time = time + 10; ... # one process fork; # two here fork; # four here fork; # eight here fork; # 16 fork; # 32 fork; # 64 fork; # 128 here fork; # 256 here, load on something is high :) # fork; # 512 , etc # and whatever happens here will happen 256 times, in parallel, # or at least as parallel as your OS can give you select(undef,undef,undef,0.003) while(time $start_time); # wait for trigger ... # connect and crash server -- David L Nicol Dickenson on the flag http://cronos.advenge.com/pc/EmilyDickenson/SecondBook/p39.html