in reply to How to convert a shell script to Perl?

I don't know why, but I thought I'd give it a try ;)

I'm not too well versed with shell scripting, but it appears as though this might be a start:

#!/usr/bin/perl use warnings; use strict; if ( ! $ARGV[0] ){ print "Usage: $0 patch_file\n"; exit; } my $patch = $ARGV[0]; my $url = "http://updates.oracle.com/Orion/Download/"; print "\nEnter metalink username: "; my $username = <STDIN>; print "\nEnter metalink password: "; my $password = <STDIN>; chomp( $username, $password ); my $fetch = "wget " . "--http-user=$username " . "--http-password=$password " . "--no-check-certificate " . "--output-document=$patch " . "$url"; `$fetch`;

Steve

Replies are listed 'Best First'.
Re^2: How to convert a shell script to Perl?
by salva (Canon) on Jun 30, 2010 at 13:03 UTC
    I hope the users are not using funny passwords as for instance ";rm -Rf /;"!!!

    Instead of the backquote operator it is safer to use system @array to call external programs:

    system ('wget', "--http-user=$username", "--http-password=$password", "--no-check-certificate", "--output-document=$path", $url);
    That way special characters are not expanded and/or interpreted by the shell in unexpected ways.

      Thanks for the tip

      I haven't had the need for system or backticks in a very long time, so that's a good reminder. Besides, the OP needs to do *some* of the work ;)

      Steve