THIS IS THE TEXT FILE.................................
SERVER put_hostname_here ANY No Key 2007
VENDOR netcool 3773
MY REQUIREMENT IS IT HAS TO CHANGE TO
SERVER 192.18.28.36 ANY No Key 73744
VENDOR netcool 8389
FOR NUMBER OF FILES
PLS GIVE ME THE SOLUTION OR SCRIPTS FOR THIS
5 1347
Welcome to TSDN.
We are here to assist others who need help with code that they have written. Please post your code so that we may do the same for you. Here a couple of great resources for those learning Perl. Learning Perl perldoc
Regards,
Kevin
Welcome to TSDN.
We are here to assist others who need help with code that they have written. Please post your code so that we may do the same for you. Here a couple of great resources for those learning Perl. Learning Perl perldoc
Regards,
Kevin
You can always read the online book, Beginning Perl as well.
Regards,
Jeff
- #!/usr/bin/perl
-
################################################################
-
#SCRIPT FOR CHANNING THE THE LICENSE_HOSTNAME,PORT NUMBER AND VENDOR PORT IN THE LICENSE FILE
-
################################################################
-
-
my $dirtoget="/export/home/guru/workspace/test/etc";
-
-
##########################
-
#FUNCTION TO SET THE LICENSE_HOSTNAME
-
###########################
-
-
sub sethost
-
{
-
my $file = shift;
-
open(THISFILE, "< $dirtoget/$file");
-
my @lines = <THISFILE>;
-
close(THISFILE);
-
my $hostname = "172.18.20.53";
-
foreach my $item(@lines)
-
{
-
my $match = "SERVER";
-
if(substr($item,0, length($match)) =~/$match/)
-
{
-
my @field = split(/ /,$item);
-
$field[1] = $hostname;
-
substr($item,0,length($item)) = "" ;
-
$item = $field[0]." " . $field[1]." ".$field[2]." ".$field[3].$field[4];
-
}
-
}
-
open(OUTPUT, "> $dirtoget/$file");
-
print OUTPUT @lines;
-
close(OUTPUT);
-
}
-
-
#############################
-
#FUNCTION TO SET THE LICENSE_PORT_NUMBER
-
#############################
-
-
sub setport
-
{
-
my $file = shift;
-
open(THISFILE, "< $dirtoget/$file");
-
my @lines = <THISFILE>;
-
close(THISFILE);
-
my $portname = "0786";
-
foreach my $item(@lines)
-
{
-
#print $item;
-
my $match = "ANY";
-
if($item=~/$match/)
-
{
-
my @field = split(/$match/,$item);
-
# substr($item,0,length($item)) ="";
-
$item = $field[0].$match." ".$portname."\n";
-
}
-
}
-
open(OUTPUT, "> $dirtoget/$file");
-
print OUTPUT @lines;
-
close(OUTPUT);
-
-
############################
-
#FUNCTION TO SET THE VENDOR_PORT_NUMBER
-
#############################
-
-
sub setvendorport
-
{
-
my $file = shift;
-
open(THISFILE, "< $dirtoget/$file");
-
my @lines = <THISFILE>;
-
close(THISFILE);
-
my $vendorportname = "7860";
-
foreach my $item(@lines)
-
{
-
my $match = "VENDOR";
-
if($item=~/$match/)
-
{
-
my @field = split(/ /,$item);
-
$field[2] = $vendorportname ;
-
# substr($item,0,length($item)) ="";
-
$item = $field[0]." " .$field[1]." ".$field[2]."\n";#." ".$field[4];
-
}
-
}
-
open(OUTPUT, "> $dirtoget/$file");
-
print OUTPUT @lines;
-
close(OUTPUT);
-
}
-
-
########################################################
-
#TO OPEN A DIRECTORY AND READ THE CONTENT OF THE DIRECTORY
-
########################################################
-
-
opendir(FILEHANDLE, $dirtoget) || die("Cannot open directory");
-
@lines= readdir(FILEHANDLE);
-
closedir(FILEHANDLE);
-
#print "@lines ";
-
foreach my $file (@lines)
-
{
-
-
if($file =~ /.lic/)
-
{
-
sethost($file);
-
setport($file);
-
setvendorport($file);
-
#print $file . "\n";
-
}
-
}
Judging by the code, I'd say you're not a perl programmer.
Judging by the code, I'd say you're not a perl programmer.
hello sir,
pls send me a code to change the content of text file dynamically.
thank you
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Hans A |
last post by:
I have a textfile "textfile.txt" containing a list of words. There is
one word on each line. I want to pick two random lines from this
textfile, and I have tried to do something like:
//Loading...
|
by: TheKeith |
last post by:
I don't know much about javascript, so take it easy on me. Is there a way to
dynamically change a CSS layers dimensions on the fly. Here is what I'm
doing. I have a bunch of thumbnails that when...
|
by: Amir Eshterayeh |
last post by:
Dear Friends
I need to change the css file of my aspx files dynamically so users can
choose their css file names and when page loads, it read css file name from
database.
I try to use...
|
by: michael |
last post by:
I have an html text string within a div, eg.:
<div id="example">Text text text</div>
I know its easy to change styles by using getElementById - for example:
...
|
by: Amir Eshterayeh |
last post by:
Dear Friends
I want to change the name of my css file dynamically so
as Mr. Jos Branders helped me, I can change the <head> tag into an HTML
control like this:
<head id="myhead" runat="server">...
|
by: G.Esmeijer |
last post by:
Friends,
I have have filled a datagrid (flexgrid from C1Components) with the content
of a textfile.
Now I would like to save the content to an access table.
I've tried the insert command I have...
|
by: Phil Hey |
last post by:
Hi,
I can change the icon for a folder by right clicking on it > going to the
customize tab > and selecting Choose Picture.
Does anyone know if it is possible to do this programmatically...
|
by: ad |
last post by:
Hi,
How can I dynamically change the MasterPager of a web page?
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |