venugopal has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: How to convert a shell script to Perl?
by Argel (Prior) on Jun 30, 2010 at 23:05 UTC
    Maybe we should make a poll to pick a better title for the OP. I'll start the list off with:
    • Hey you! Yeah you! Convert this damn shell script for me. And have it done by yesterday!
    • Any suckers out there willing to do my job for me?
    • Are you bored? Do you have a giving nature? Then have I got a project for you!
    • Hey, how can I lose some XP real fast?
    • I'm working on my hubris and laziness. How do you think I'm doing?
    Last one is my personal favorite! :-)

    Elda Taluta; Sarks Sark; Ark Arks

Re: Answer: How to convert a shell script to Perl?
by Anonymous Monk on Jun 30, 2010 at 10:35 UTC
    hi please post credit card number so I can charge fee for work
Re: How to convert a shell script to Perl?
by stevieb (Canon) on Jun 30, 2010 at 12:44 UTC

    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

      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