canasia.org

 
  • Narrow screen resolution
  • Wide screen resolution
  • Increase font size
  • Decrease font size
  • Default font size
  • default color
  • dark color
  • red color
Forums
Welcome, Guest
Please Login or Register.    Lost Password?
running for beginners Creating PID file (1 viewing) (1) Guests
Go to bottom Post Reply Favoured: 0
TOPIC: running for beginners Creating PID file
#3686
Richard Lee (Visitor)
Click here to see the profile of this user
Birthdate:
running for beginners Creating PID file  
Hello guys,  I want to start learning about sql and how it interacts w/ perl.  My rough idea is to install mysql server and read some books to start playing w/ it along w/ perl.  Any advice? thanks.. my weekend project to get this going.. so I will update w/ more questions..
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#3687
Michael Barnes (Visitor)
Click here to see the profile of this user
Birthdate:
running for beginners Creating PID file  
This may be a bit advanced for a beginner's group, but I need to have my _script_ create a pidfile.  I'm running a monitor app that keeps track of what is running and notifies me when stuff stops.  It does it by comparing the pid in the pidfile with ps.  So, I need my _script_ to create a pidfile when it starts. Ideas appreciated. This is far more than a beginners' group, but your post is heavy with Unix terminology. Remember that this is a cross-platform group. I know that a PID is a process ID, and I can imagine what a 'pidfile' might be, but 'comparing the pid in the pidfile with ps' is nonsense. Explain the problem, and we will help to solve it. Rob
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#3688
running for beginners Creating PID file  
Hi, Search on search.cpan.org for File:ID and download and install that module. It might help you to create PID files. To clarify the need for using a PID file, I think it needs to be used for example when somebody wants to run a program manually or from a chron job but when the admin doesn't want to run the program twice, so he should verify if that program is running. The program runs, opens the PID file, gets the PID from there and verifies if there is a program with that PID which is running in that moment. The program can't verify in another way if it is running, because the same program may be ran with different command lines or _link_s to it. Am I wrong? Octavian - Ukryj cytowany tekst -- Pokaż cytowany tekst -
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#3689
running for beginners Creating PID file  
Hi, You didn't say if you are running Windows, Linux or something else... If you have Linux, you probably already have perl. If you use Windows, get and install perl from www.activestate.com. You must also get and install MySQL from www.mysql.com if you don't have it installed. Then you need to install the modules DBI and DBD::mysql using (under Unix/Linux): $ cpan cpan install DBI cpan install DBD::mysql or cpan force install DBD::mysql Then you could read more about these modules using: $ perldoc DBI $ perldoc DBD::mysql and you can start using them like: my $dbh = DBI-connect( dbi:mysql:data_base_=test , username , thePassword ); #Create a table $dbh-do( create table foo(id int unsigned not null autoincrement primary key, body text) ); #Insert a few rows my $sth = $dbh-prepare( insert into foo(id, body) values(?, ?) ); my @bodies = qw/foo bar baz/; foreach my $body(@bodies) { $sth-execute(undef, $body); } #select a row my $sth2 = $dbh-prepare( select id, body from foo where id=? ); $sth2-execute(3); my ($id, $body) = $sth2-fetchrow_array; You will find many ways of using DBI from the POD doc. HTH. Octavian - Ukryj cytowany tekst -- Pokaż cytowany tekst -
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#3690
Chas. Owens (Visitor)
Click here to see the profile of this user
Birthdate:
running for beginners Creating PID file  
My apologies.  I know this is a cross-platform group, and that is fine.  However, if you are unable to understand simple Linux terminology, then it is doubtful that you can help answer my question.  If the de_script_ion is nonsense to you, then please don't waste your or my time in an apparent slam on my choice of operating systems.  If your reply represents the general attitude of this list, then it looks like I've come to the wrong place for assistance.  But, to simplify my request, a pid is a process id.  In Linux, the command 'ps' will give a listing of process IDs.  I need the _script_ to determine its own pid, then write that to a file. snip The variable $$ holds the PID for the current program*.  Typically a pidfile is created in /var/run by saying something like use strict; use warnings; use File::_base_name; BEGIN {     our $program = _base_name $0;     die $program already runningn if -f /var/run/$program ;     open my $pidfile, , /var/run/$program         or die could not open /var/run$program: $! ;     print $pidfile $$n ;     close $pidfile; } #make sure the last thing done is the removal of the pidfile #note: this happens even if we die END {     our $program;     un_link_( /var/run/$program )         or die could not delete /var/run/$program ; } #the rest of your code There are also a few modules on CPAN that automate this to a certain extent for you: Proc:idfile**, File:id***, and File:id::Quick****. * see perldoc perlvar or http://perldoc.perl.org/perlvar.html#$PROCESS_ID for more information ** http://search.cpan.org/dist/Proc-Pidfile/Pidfile.pm *** http://search.cpan.org/dist/File-Pid/lib/File/Pid.pm **** http://search.cpan.org/dist/File-Pid-Quick/Quick.pm
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#3691
J. Peng (Visitor)
Click here to see the profile of this user
Birthdate:
running for beginners Creating PID file  
#make sure the last thing done is the removal of the pidfile #note: this happens even if we die END {   our $program;   un_link_( /var/run/$program )      or die could not delete /var/run/$program ; } As I have said (in fact it's said by Lincoln Stein), you should add a if statement here to avoid the childs delete the pid file when they're exiting. if ( $$ == $pid ) { # $pid is parent's pid     un_link_ $pidfile or die $!; }
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop
Advertisement

www.yoursite.com
canasia.org
Compare garmin nuvifone
Buy compare &read about the Garmin nuvifone. Guaranteed next working day delivery service available online in UK.

Pozycjonowanie stron internetowych Cheap flights to Miami - Manual Treadmills - Camping Equipment - Melt It Off
iron foundry - Money online - Galeria de Arte - so lange nicht geschriebens so - Mieszkania i Nieruchomości - teksty piosenek - Web Directory - pozycjonowanie - Masuren - marijuana detox
śmieszne filmy
śmieszne filmy
www.kawe.pl
kalkulator kredytowy
Kredyty mieszkaniowe, hipoteczne
www.kredytmieszkani…
odtwarzacze MP3
odtwarzacze mp3
www.sirius.pl
Pozycjonowanie strony
Pozycjonowanie
www.truvati.pl
Darmowe gry
darmowe gry, gry
www.gry.freetravel.…
książki informatyczne kreator www konferencje opis twojemiasteczkopoznan.pl mapa