![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| perl: simple question on string append | the_learner | Shell Programming and Scripting | 1 | 05-14-2007 06:09 PM |
| Why this simple script, is not working ? | so_friendly | Shell Programming and Scripting | 4 | 07-11-2006 04:05 AM |
| how to change working directories in perl? | megastar | Shell Programming and Scripting | 1 | 11-02-2005 03:05 PM |
| Simple Perl Script to Screen Display | Shakey21 | Shell Programming and Scripting | 1 | 04-19-2002 12:55 PM |
| a simple perl | gusla | UNIX for Dummies Questions & Answers | 3 | 04-17-2002 03:01 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
simple perl script not working
why won't below work?
I am trying to see a)sipfile has username of the system. b)it will read the sipfile and do a grep function against the /etc/passwd c)it will save that output to /tmp/result.. but my script is just hanging... #!/usr/bin/perl -w open(SIPFILE, "</tmp/sipfile") or die "Couldn't find the /tmp/sipfile: $! \n"; open(RESULT, ">>/tmp/result"); my $line; while (<SIPFILE>) { $line = `grep $_ /etc/passwd`; print RESULT $line; } close(SIPFILE); close(RESULT); |
|
||||
|
I clearly see that /tmp/sipfile has
user1 user2 user3 user4 and I see end of line($) through vi... but when I run the script, it shows the entire /etc/passwd file in /tmp/result. what am I doing wrong?? #!/usr/bin/perl -w open(SIPFILE, "</tmp/sipfile"); open(RESULT, ">>/tmp/result"); while (<SIPFILE>) { chomp; $line = `grep \$_ /etc/passwd`; print RESULT $line; } close(SIPFILE); close(RESULT); |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|