Re: Help me to run linux command in windows
by polettix (Vicar) on Aug 22, 2007 at 10:22 UTC
|
If another way is there then fine...
Another way for doing what? If you're only looking for a way to obtain the list of files in a directory, you could go low-level with opendir/readdir/closedir, or try to take a look to the more structured approaches offered by File::Find and its colleagues on CPAN.
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
Don't fool yourself.
| [reply] |
Re: Help me to run linux command in windows
by bart (Canon) on Aug 22, 2007 at 10:34 UTC
|
If your aim is to write portable code, then don't depend on external programs for such simple tasks. | [reply] |
Re: Help me to run linux command in windows
by moritz (Cardinal) on Aug 22, 2007 at 10:29 UTC
|
Instead of `ls` you can use glob('*'). | [reply] [d/l] [select] |
Re: Help me to run linux command in windows
by Anonymous Monk on Aug 22, 2007 at 11:13 UTC
|
Make a file called ls.bat and put it in a system directory (like system32 or Windows). Put
dir %1
in the file. Reading your post again it seems like you want to call it from within an application - if it's a windows app, then why not just use 'dir'? | [reply] |
Re: Help me to run linux command in windows
by technojosh (Priest) on Aug 22, 2007 at 14:00 UTC
|
This should work on windows just fine:
my $fileDir = someawesomepath;
opendir(DIR, "$fileDir") || die $!;
while (defined(my $file = readdir(DIR))) {
next if $file =~ /^\.\.?$/; # Skip the DIR
#do stuff with $file
}
closedir(DIR);
| [reply] [d/l] |
Re: Execute Perl Under Cygwin in Windows!!! Help!!!
by Tux (Canon) on Aug 22, 2007 at 10:45 UTC
|
opendir DIR, "." or die "$!";
foreach my $dir (grep { -d $_ } readdir DIR) {
# Do something with $dir
}
closedir DIR;
Using File::Find might be an option too
Enjoy, Have FUN! H.Merijn
| [reply] [d/l] |
Re: Help me to run linux command in windows
by syphilis (Archbishop) on Aug 23, 2007 at 08:34 UTC
|
I installed cygwin and activeperl
Since you have cygwin, you could just run 'ls' in cygwin's bash shell ... and use cygwin's perl (in the same shell) instead of ActivePerl.
But if you want to use ActivePerl, and still be able to run 'ls', then just add C:\cygwin\bin to the end of the path environment variable. (That's assuming you've installed Cygwin into C:\cygwin - otherwise amend accordingly.)
Cheers, Rob | [reply] |
|
|
Hi All,
Many thanks!! What i did is adding the cygwin bin to the path variable so ls started working and my coding has succedded.........Thanks!!!
| [reply] |
Re: Help me to run linux command in windows
by Anonymous Monk on Aug 22, 2007 at 18:05 UTC
|
If your question is how to make the "ls" command run under windows, then one "simple" way would be to create a batch file in the windows/system32/ (or other directory sitting in the execution path) that will execute the cygwin'd ls perl script for you. | [reply] |
Re: Help me to run linux command in windows
by nega (Scribe) on Aug 22, 2007 at 20:34 UTC
|
| [reply] |
Re: Execute Perl Under Cygwin in Windows!!! Help!!!
by Razvanica (Novice) on Aug 22, 2007 at 10:14 UTC
|
I don't really understand what you are trying to do, but Windows has the 'dir' command which does almost the same thing as 'ls' on Linux. | [reply] |
|
|
I wanted the output format of ls command from windows but dir gives out junk data... Because my application has to login to each of the folders and process files and update DB.
| [reply] |