LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Closed Thread
  Search this Thread
Old 08-16-2012, 05:49 PM   #1
darthlefein
LQ Newbie
 
Registered: Aug 2012
Posts: 4

Rep: Reputation: Disabled
What's wrong with my script


What's wrong with it

Code:
#!/usr/bin/perl -w

use CGI qw(:all);;
use Fcntl qw(:flock);


my $mldata="onemoretime.txt";
my $semaphore_file="onemoretime.txt";

$file='SnPmaster.txt';
open(INFO, $file) or die("Could not open file.");

$count = 0;
foreach $line (<INFO>) {
print $line;
if ($++counter == 2){
last;
}
}
close(INFO);


sub get_lock {
open(SEM, "$onemoretime.txt") || die "Cannot open $onemoretime.txt : $!";
flock SEM, LOCK_EX;
}


#
sub release_lock {
close(SEM);
}



get_lock();
open(GB, ">>$mldata") || die "Cannot open $mldata: $!";
print GB "address: ", param('_ADDRESSVARIABLE'), "\n";
close(GB);
release_lock();
}

Last edited by darthlefein; 08-16-2012 at 05:53 PM.
 
Old 08-16-2012, 05:51 PM   #2
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Quote:
What's wrong with my script
First of all, it's not wrapped in the 'code' tags.
 
Old 08-16-2012, 06:01 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
2nd do not create duplicate threads on the same topic. This thread is being closed because it is a duplicate.

Continue here:
http://www.linuxquestions.org/questi...xt-4175422485/
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
what's wrong with this script? frieza Programming 1 03-13-2011 11:18 PM
What is going wrong with this script? Thaidog Programming 3 12-18-2010 01:48 PM
What is wrong with the following script? lukea37 Programming 4 09-10-2005 08:34 AM
My first BASH script, what's wrong with it? szf2 Linux - Newbie 2 11-12-2003 01:43 PM
What's wrong with my script ? kalmen Linux - General 6 12-28-2002 06:36 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration