Sponsored Content
Full Discussion: use perl to get file type ?
Top Forums Shell Programming and Scripting use perl to get file type ? Post 302142524 by cbkihong on Friday 26th of October 2007 10:04:59 PM
Old 10-26-2007
For symbolic links, you should use lstat() to test rather than stat().

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

use Fcntl ":mode"; 

my @files = ("/etc/rc5.d/S99rc.local", "users.ini");

foreach (@files) {
	my @attrs = lstat($_); 
	print (S_ISLNK($attrs[2])?"$_: Is a Link\n":"$_: Not a Link\n");
}

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

determine file type with perl

Hello i will like to know please how can i determine file type inside perl script not using the unix "file" program Thanks allot (1 Reply)
Discussion started by: umen
1 Replies

2. Shell Programming and Scripting

how to get type of variable in perl

hello all how can i get the type of variable in perl like typeof(var); in javascript for instance ? to know if the variable is int or string ? (2 Replies)
Discussion started by: umen
2 Replies

3. Programming

array type has incomplete element type

Dear colleagues, One of my friend have a problem with c code. While compiling a c program it displays a message like "array type has incomplete element type". Any body can provide a solution for it. Jaganadh.G (1 Reply)
Discussion started by: jaganadh
1 Replies

4. Shell Programming and Scripting

Perl data type checking

I am using perl 5.8.0. I need to check some values to see it they are floats. Our system does not have Data::Types so I can't use is_float. Is there something else that I can use? The only thing in Data is Dump.pm. I am not allowed to download anything to our system so I have to use what I have.... (3 Replies)
Discussion started by: ajgwin
3 Replies

5. Shell Programming and Scripting

Perl variable type assessment

Hello experts, How we can find out,that what is type of a scalar variable? i.e a scalar var contain a number or a string. Thanks in advance. (8 Replies)
Discussion started by: Zaxon
8 Replies

6. Shell Programming and Scripting

what is the default return type of localtime() in perl?

Hi, I have given like this to get the time of the sub routine. my $start = localtime(); print "\n start time: $start \n"; Output start time: Fri Apr 29 01:01:31 2011 I want to know what is the format of the time. I am not able to follow is is HH:MM:SS or MM:HH:SS os... (2 Replies)
Discussion started by: vanitham
2 Replies

7. Shell Programming and Scripting

How can i use switches type arguments for subroutines in perl

i want to call subroutines in perl like: sub temp { ---- some code ----- } temp(-switchName, value1, --switchName2, value2) Like i know getoptions::Long is there for command line switches type arguments. So i want to know for subroutine type arguments. (1 Reply)
Discussion started by: Navrattan Bansa
1 Replies

8. Shell Programming and Scripting

[solved] File type error (not a regular file)

Hi friend, i have written script as below to check the file existance. but i got error path="/k/p1100/users/jewel/Output" FILENAME=`ls -lrt $path/*HT|tail -1|cut -d "/" -f 8` if ; then echo "$FILENAME is available " chmod 755 $path/$FILENAME /usr/bin/scp... (0 Replies)
Discussion started by: Jewel
0 Replies

9. Shell Programming and Scripting

Shell script to read file and check file type

Hi, I have a file with few values in it. I need script help to read file line by line and check: 1/if it's a file (with extension eg .java .css .jar etc ) or 2/if it's a file without extension and treat it as a directory and then check if the directory exists in working copy else create one... (6 Replies)
Discussion started by: iaav
6 Replies
attroff(3cur)															     attroff(3cur)

Name
       attroff, attron, attrset, standend, standout, wstandend, wstandout, wattroff, wattron, wattrset - attribute manipulation

Syntax
       #include <cursesX.h>

       int attroff(attrs)
       int attrs;

       int wattroff(win, attrs)
       WINDOW *win;
       int attrs;

       int attron(attrs)
       int attrs;

       int wattron(win, attrs)
       WINDOW *win;
       int attrs;

       int attrset(attrs)
       int attrs;

       int wattrset(win, attrs)
       WINDOW *win;
       int attrs;

       int standend()

       wstandend(win)
       WINDOW *win;

       int standout()

       int wstandout(win)
       WINDOW *win;

Description
       These routines manipulate the current attributes of a window.

       The routine turns off the named attributes (of the default window without turning any other attributes on or off.

       The routine turns on the named attributes of the default window without affecting any other attributes.

       The  routine  sets  the	current attributes of the default window to the named attributes which is of the type and is defined in the header
       file.

       The routine switches on the best highlighting mode available on the terminal for the default window and it is functionally the same as

       The routine switches off all highlighting associated with the default window.  It is functionally the same as in  that  it  turns  off  all
       attributes.

       The routine switches off the named attributes, for the specified window.  Other attributes are not changed.

       The routine turns on the named attributes of the specified window without affecting any others.

       The routine sets the current attributes of the specified window to

       The routine switches on the best highlighting mode available on the terminal for the specified window.  Functionally it is the same as

       The  routine  switches off all highlighting associated with the specified window.  Functionally it is the same as that is, it turns off all
       attributes.

Attributes
       Attributes can be any combination of A_STANDOUT, A_REVERSE, A_BOLD, A_DIM, A_BLINK and A_UNDERLINE.  These constants  are  defined  in  the
       header  file.   They are also described in the Guide to X/Open Curses Screen-Handling.  (R)Attributes can be combined with the C language |
       operator.

       The current attributes of a window are applied to all characters that are written into the window with or Attributes are properties of  the
       character,  and	move with the character through any scrolling and insert/delete line/character operations.  Within the restrictions set by
       the terminal hardware they will be displayed as the graphic rendition of characters put on the screen.

       The routines and are macros.

Return Values
       The and functions return OK on success and ERR on error.

See Also
       addch(3cur)
       Guide to X/Open Curses Screen-Handling

																     attroff(3cur)
All times are GMT -4. The time now is 12:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy