1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2008
    Rep Power

    [HELP] convert Perl script to Bash shell script

    Hi everybody;

    Need help converting the following Perl script to Bash shell script :
    #!/usr/bin/perl -w
    $SIG{INT} = 'IGNORE';
    $SIG{TSTP} = 'IGNORE';
    $SIG{TERM} = 'IGNORE';
    $SIG{QUIT} = 'IGNORE';
    print " Challenge1 : ";chomp($a=<STDIN>);
    print " Challenge2 : ";chomp($b=<STDIN>);
    while ($a ne  "123456" || $b ne "456789"){
    print " Challenge1 : ";chomp($a=<STDIN>);
    print " Challenge2 : ";chomp($b=<STDIN>);
    I understand it's a simple while loop checks the STDIN values "Challenge1, and Challenege2" compared to "123456 and 456789" if correct it exit the loop or else ask for Challenges again. I'm pretty sure it's a nooby question and I'd better to learn Shell scripting but I really need it as soon as possible.

    Also I've another question; How to store the reference values(i.e; 123456 and 456789) of Challenge1 and Challenge2 in an encrypted form say MD5 and even more save those values in another text file rather than showing them in the same shell script (i.e; compare STDIN to reference values in /home/user/challenges.txt).

    Thanks in advance ;
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2007
    Rep Power
    The best solution is don't use bash for this; there are plenty of good ways to authenticate a user (pam(8)).

    If you must do this in bash for some reason read the man page for bash paying attention to the built-ins.

    For hashing you can look at utilities like sha1sum(1) or openssl's dgst(1).

    If you need help, post your attempt (placing your code/data in [code][/code] tags so it's legible!) and ask a specific question (showing any relevant error messages or input/output). You're unlikely to get a complete script written for you--that's not what these forums are for.
    sub{*{$::{$_}}{CODE}==$_[0]&& print for(%:: )}->(\&Meh);

IMN logo majestic logo threadwatch logo seochat tools logo