The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
script for download files from ftp site tiff-matt Shell Programming and Scripting 5 09-19-2008 03:46 PM
Download files using perl mirusnet UNIX for Dummies Questions & Answers 2 12-19-2007 10:04 PM
download files from direct links tool? umen UNIX for Dummies Questions & Answers 2 07-04-2006 11:00 AM
shellscript for download files ram2s2001 Shell Programming and Scripting 3 02-07-2006 08:16 AM
How to download Red hat plz Hlp ? atiato UNIX for Dummies Questions & Answers 3 02-05-2002 01:21 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-16-2008
imad77 imad77 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 20
download files

Hi,
I experience some difficulties to perform a script to be able to download some files via HTTP.

The Perl script is located on a Linux in a server ("/var/www/cgi-bin/down.pl") where I can run it via Internet Explorer.

I'm able to display the directory content ("/home/toto") but I'm not able to open or save the files from this directory to my local machine (Windows XP by example).

My goal is to be able to save a file when I click on them and choose the target on my local machine.

Can someone help me to fix this script? thanks in advance.

Code:
#!/usr/bin/perl
use CGI;
$|=1;
my $query=new CGI;
print qq~
<table align="center" width="90%">
<tr><td><font color="black" face="Arial" size="4"><b>Files in current directory</b></td></tr>
<tr>
<td valign="top">
<font color="black" face="Arial" size="2">
~;
$dir="/home/toto";
opendir(DIR, "$dir");
@current = readdir(DIR);
closedir(DIR);

foreach(@current){
unless($_ eq '.' || $_ eq '..' || -d qq~$dir/$_~){
push(@currentfiles, $_);
}
}
@currentfiles = sort { uc($a) cmp uc($b) } @currentfiles;
for($aa = 0; $aa <= $#currentfiles; $aa++){
print qq~

<a href="$dir/$currentfiles[$aa]" target="_blank">$currentfiles[$aa]</a><a href="$dir/$currentfiles[$aa]"> </a></font><br>
~;
}
print qq~
</font></tr>
</table>

Last edited by otheus; 03-08-2009 at 11:42 AM.. Reason: code tags added
  #2 (permalink)  
Old 11-17-2008
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,944
The links won't work if your webserver is not configured to allow access these files, and your webserver can probably make its own listing of them anyway, no script required.

Also, please put code in [ code ] code tags [ /code ], it makes it much more readable.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0