Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Read directory and fill a file with this information Post 302315774 by jim mcnamara on Wednesday 13th of May 2009 07:48:57 AM
Old 05-13-2009
Code:
ls /tempdir |
while read filename
do
echo "this filename $filename is found and would be removed within 10 days"
done >> /test/output

Note: if the directory /test exists it is a really bad name for a file or a directory.
test is the name of a unix command. file names that match command names cause problems.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

File/directory information......

Basically i have done created the script below, and it functions ok, it prints the access rights the user has. But i need it to print the group permissions, and other permissions, it would also be helpful if i could print the permissions in numeric form aswell, if it is possible. I have looked in... (50 Replies)
Discussion started by: Makaveli.2003
50 Replies

2. Shell Programming and Scripting

Urgent!!!Read directory from a file

I have a receive script file which had lots of direcorties to process,but now,I don't want to hardcode them,I need input the directory name in a Property.txt file,then write shell code to read the directory name from Property.txt to the script file so I can get flexible on it.But when I ran the sh... (3 Replies)
Discussion started by: joshuaduan
3 Replies

3. Programming

How to read and write directory or file contents in c++ ?

Dear Friends, I m beginner unix programmer. I want to know, how to read and write directory or file contents in c++ ? (3 Replies)
Discussion started by: namrata5
3 Replies

4. Shell Programming and Scripting

How to read file names in the directory?

I am having n files in a directory i want to read all the file names from the script file .It is better if any one provide a sample script. Elaborating the scenario: i am having n number of sql files in a directory i am running all the sql files from a single script. sqlplus... (4 Replies)
Discussion started by: dineshmurs
4 Replies

5. Shell Programming and Scripting

read file by file in a directory

Hi I have directory which has 5 files names test1, test2, test3, test4, test5 Now i want to read file by file and generate md5checksum. Command used is md5sum test1. How can i read file names one after the other and generate checksum and send the output to a file. Please reply (3 Replies)
Discussion started by: vasuarjula
3 Replies

6. Programming

How to read BGP session information with C

Friends, I want to read BGP session information with C ( in FreeBSD ). The program will almost work like a sniffer. My FreeBSD box (which is not a BGP speaker) will look at BGP session information (after catching and parsing it) and take a decision based on the information it sees. :wall: ... (1 Reply)
Discussion started by: asadfx
1 Replies

7. Shell Programming and Scripting

Fill the directory

HI all When i do df -h,it displays the amount of free space. Tell me a command or a script to fill the total space to a certain percent (say 99%) Thanks in advance (8 Replies)
Discussion started by: 2002anand
8 Replies

8. Shell Programming and Scripting

How to read userid and password information from txt file

Hi Experts, I am writing a shell script (for displaying disk space details) which is logging to 15 different servers using following command. ssh userid@servername It is prompting me for password for all 15 servers when I manually run it. However , soon I would like to schedule this script... (4 Replies)
Discussion started by: ajaypatil_am
4 Replies

9. UNIX for Dummies Questions & Answers

How can I use my code to gather information from a file in a completely different directory?

I need my code to compare two different files that are in two completely different directories, How can I do this? So for example, my code will look at file1 which is in my home directory, and compare the files with those from file2 that is in /abc/adf/adr/afc/adf/file2... does that make sense? (1 Reply)
Discussion started by: castrojc
1 Replies
Test::Perl::Critic::Policy(3)				User Contributed Perl Documentation			     Test::Perl::Critic::Policy(3)

NAME
Test::Perl::Critic::Policy - A framework for testing your custom Policies SYNOPSIS
use Test::Perl::Critic::Policy qw< all_policies_ok >; # Assuming .run files are inside 't' directory... all_policies_ok() # Or if your .run files are in a different directory... all_policies_ok( '-test-directory' => 'run' ); # And if you just want to run tests for some polices... all_policies_ok( -policies => ['Some::Policy', 'Another::Policy'] ); # If you want your test program to accept short Policy names as # command-line parameters... # # You can then test a single policy by running # "perl -Ilib t/policy-test.t My::Policy". my %args = @ARGV ? ( -policies => [ @ARGV ] ) : (); all_policies_ok(%args); DESCRIPTION
This module provides a framework for function-testing your custom Perl::Critic::Policy modules. Policy testing usually involves feeding it a string of Perl code and checking its behavior. In the old days, those strings of Perl code were mixed directly in the test script. That sucked. NOTE: This module is alpha code -- interfaces and implementation are subject to major changes. This module is an integral part of building and testing Perl::Critic itself, but you should not write any code against this module until it has stabilized. IMPORTABLE SUBROUTINES
all_policies_ok('-test-directory' => $path, -policies => @policy_names) Loads all the *.run files beneath the "-test-directory" and runs the tests. If "-test-directory" is not specified, it defaults to t/. "-policies" is an optional reference to an array of shortened Policy names. If "-policies" specified, only the tests for Policies that match one of the "m/$POLICY_NAME/imx" will be run. CREATING THE *.run FILES Testing a policy follows a very simple pattern: * Policy name * Subtest name * Optional parameters * Number of failures expected * Optional exception expected * Optional filename for code Each of the subtests for a policy is collected in a single .run file, with test properties as comments in front of each code block that describes how we expect Perl::Critic to react to the code. For example, say you have a policy called Variables::ProhibitVowels: (In file t/Variables/ProhibitVowels.run) ## name Basics ## failures 1 ## cut my $vrbl_nm = 'foo'; # Good, vowel-free name my $wango = 12; # Bad, pronouncable name ## name Sometimes Y ## failures 1 ## cut my $yllw = 0; # "y" not a vowel here my $rhythm = 12; # But here it is These are called "subtests", and two are shown above. The beauty of incorporating multiple subtests in a file is that the .run is itself a (mostly) valid Perl file, and not hidden in a HEREDOC, so your editor's color-coding still works, and it is much easier to work with the code and the POD. If you need to pass any configuration parameters for your subtest, do so like this: ## parms { allow_y => '0' } Note that all the values in this hash must be strings because that's what Perl::Critic will hand you from a .perlcriticrc. If it's a TODO subtest (probably because of some weird corner of PPI that we exercised that Adam is getting around to fixing, right?), then make a "##TODO" entry. ## TODO Should pass when PPI 1.xxx comes out If the code is expected to trigger an exception in the policy, indicate that like so: ## error 1 If you want to test the error message, mark it with "/.../" to indicate a "like()" test: ## error /Can't load Foo::Bar/ If the policy you are testing cares about the filename of the code, you can indicate that "fcritique" should be used like so (see "fcritique" for more details): ## filename lib/Foo/Bar.pm The value of "parms" will get "eval"ed and passed to "pcritique()", so be careful. In general, a subtest document runs from the "## cut" that starts it to either the next "## name" or the end of the file. In very rare circumstances you may need to end the test document earlier. A second "## cut" will do this. The only known need for this is in t/Miscellanea/RequireRcsKeywords.run, where it is used to prevent the RCS keywords in the file footer from producing false positives or negatives in the last test. Note that nowhere within the .run file itself do you specify the policy that you're testing. That's implicit within the filename. BUGS AND CAVEATS AND TODO ITEMS
Add policy_ok() method for running subtests in just a single TODO file. Can users mark this entire test as TODO or SKIP, using the normal mechanisms? Allow us to specify the nature of the failures, and which one. If there are 15 lines of code, and six of them fail, how do we know they're the right six? Consolidate code from Perl::Critic::TestUtils and possibly deprecate some functions there. Write unit tests for this module. Test that we have a t/*/*.run for each lib/*/*.pm AUTHOR
Andy Lester, Jeffrey Ryan Thalhammer <thaljef@cpan.org> COPYRIGHT
Copyright (c) 2009-2011 Andy Lester. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. perl v5.16.3 2014-06-09 Test::Perl::Critic::Policy(3)
All times are GMT -4. The time now is 02:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy