Sponsored Content
Top Forums Shell Programming and Scripting Perl Script not working on all directories Post 302602576 by richsark on Monday 27th of February 2012 06:43:09 PM
Old 02-27-2012
Perl Script not working on all directories

Hi Folks,

I have a script that I am using. The files are in Directory c:\files\change\options

In that directory I have many other sub folders like R1 R2 R5 E4 etc...

When I run this script in windows, It looks like its just changing the first folder R1 and not the rest.

Can I get an expert please to see why is not working.

I run it like

perl 2012-Convert-ISC-DHCP-FQDN--to--IP.pl rich-input.txt *

in Cygwin I also tried and same thing. Its just working on one folder

./2012-Convert-ISC-DHCP-FQDN--to--IP-Copy.pl rich-input.txt *


Here is the script


Code:
#!/usr/bin/perl
use File::Find;
open F,shift or die $!;
my %ip=map/(\S+)\s+(\S+)/,<F>;
close F;
find sub{
  if( -f ){
     local @ARGV=($_);
     local $^I="";
     while( <> ){
/^option\s+domain-name-servers\s.*/ &&  s/([\w.]*\w)\.?/$ip{$1}||($donthave{$1}=$1)/eg;
           print;
     }
  }
},@ARGV;
print "don't have $_ in my input file\n" for values %donthave;

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl package directories - what if the script is diff DIR to the one contain *.pm?

Hi there, say the package is in the ~/ and it's ~/packageFoo.pm I can use usePackage.pl in ~/ (~/usePackage.pl). Now, if I move it to ~/subDIR/usePackage.pl, the script won't work because it's not in the same DIR with packageFoo.pm How can i fix it? Thanks Gusla (1 Reply)
Discussion started by: gusla
1 Replies

2. Shell Programming and Scripting

how to change working directories in perl?

i am new to perl. i am writing a perl script. i want to know how to change the working directories? for ex. i have a perl script in c:\proj\ . i want to run this script in this directory but i need my script to change its working directory to D:\xyz\ dynamically in the script. your help is... (1 Reply)
Discussion started by: megastar
1 Replies

3. UNIX for Dummies Questions & Answers

Perl script not working

Hi Experts!! I have written a very simple script in perl.The script is : $ cat 1.pl #!/usr/bin/perl print "Hi there!\n"; When i ran the above perl script it is showing the following error: $ perl 1.pl -ksh: cd: bad substitution Can anybody,help on this ....as why this script is... (1 Reply)
Discussion started by: Amey Joshi
1 Replies

4. Shell Programming and Scripting

Perl script 'system' linking to local shell script not working

Trying to figure out why this works: printpwd.pl #!/usr/bin/perl use CGI::Carp qw( fatalsToBrowser ); print "Content-type: text/html\n\n"; $A = system("pwd"); $A = `pwd`; print "$A\n"; ^^actually that works/breaks if that makes any sense.. i get the working directory twice but when... (5 Replies)
Discussion started by: phpfreak
5 Replies

5. Shell Programming and Scripting

Run perl script on files in multiple directories

Hi, I want to run a Perl script on multiple files, with same name ("Data.txt") but in different directories (eg : 2010_06_09_A/Data.txt, 2010_06_09_B/Data.txt). I know how to run this perl script on files in the same directory like: for $i in *.txt do perl myscript.pl $i > $i.new... (8 Replies)
Discussion started by: ad23
8 Replies

6. Shell Programming and Scripting

executing perl script from another perl script : NOT WORKING

Hi Folks, I have 2 perl scripts and I need to execute 2nd perl script from the 1st perl script in WINDOWS. In the 1st perl script that I had, I am calling the 2nd script main.pl =========== print "This is my main script\n"; `perl C:\\Users\\sripathg\\Desktop\\scripts\\hi.pl`; ... (3 Replies)
Discussion started by: giridhar276
3 Replies

7. Shell Programming and Scripting

Perl script for finding directories with mtime

Need assistance in the perl script . Below script gives me the results of all the files and directories with mtime with no issues . But i wanted to have a file and specify all the directory locations and use that file as reference and get results . Any ideas are highly Appreciated . ... (6 Replies)
Discussion started by: ajayram_arya
6 Replies

8. Shell Programming and Scripting

How to run perl script on multiple files of two directories?

Hi I have 100 files under file A labled 1.txt 2.txt.....100.txt(made up name) I have 1 files under file B labled name.txt How can i run the same perl script on 100 files and file name.txt I want to run perl script.pl A/1.txt B/name.txt perl script.pl A/2.txt B/name.txt ....... perl... (3 Replies)
Discussion started by: grace_shen
3 Replies

9. Shell Programming and Scripting

Perl: script to work with files with the same name in different directories

Hi All, I would like to use a Perl (not Bash) script to work with multiple files of the same name in different directories (all in the same parent directory). I tried to create a loop to do so, but it isn't working. My code so far: while (defined(my $file = glob("./*/filename.txt")) or... (1 Reply)
Discussion started by: elgo4
1 Replies

10. Shell Programming and Scripting

Perl script stopped working

Hi, I have the following segment of a script which is supposed to prompt a user for password and then capture the password entered by the user. The function is called in by another script and used to work without issue, the problem is that recently the script is not waiting for the user to... (3 Replies)
Discussion started by: belalr
3 Replies
cscope-indexer(1)					      General Commands Manual						 cscope-indexer(1)

NAME
cscope-indexer - Script to index files for cscope SYNOPSIS
cscope-indexer [-v] [-f database_file] [-i list_file] [-l] [-r] DESCRIPTION
This script generates a list of files to index (cscope.out), which is then (optionally) used to generate a cscope database. You can use this script to just build a list of files, or it can be used to build a list and database. This script is not used to just build a data- base (skipping the list of files step), as this can be simply done by just calling "cscope -b". Normally, cscope will do its own indexing, but this script can be used to force indexing. This is useful if you need to recurse into sub- directories, or have many files to index (you can run this script from a cron job, during the night). It is especially useful for large projects, which can contstantly have source files added and deleted; by using this script, the changing sources files are automatically handled. Currently, any paths containing "/CVS/" or "/RCS/" are stripped out (ignored). OPTIONS
-f database_file Specifies the cscope database file (default: cscope.out). -i list_file Specifies the name of the file into which the list of files to index is placed (default: cscope.files). -l Suppress the generation/updating of the cscope database file. Only a list of files is generated. -r Recurse into subdirectories to locate files to index. Without this option, only the current directory is searched. -v Be verbose. Output simple progress messages. SEE ALSO
cscope(1) AUTHOR
This manual page was written for the Debian GNU/Linux system by Robert Lemmen <robertle@semistable.com> (but may be used by others, of course) Script to index files for cscope 30. December 2002 cscope-indexer(1)
All times are GMT -4. The time now is 04:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy