LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (http://www.linuxquestions.org/questions/red-hat-31/)
-   -   wget authntication issues on RHEL5 v. RHEL6 (http://www.linuxquestions.org/questions/red-hat-31/wget-authntication-issues-on-rhel5-v-rhel6-4175450187/)

brandoness 02-14-2013 05:07 PM

wget authntication issues on RHEL5 v. RHEL6
 
Hello,

I maintain both RHEL5 and RHEL 6 servers. In order to connect to the outside web I must first authenticated to a web proxy and if no GUI browser is available (Firefox) I used lynx.

I'm writing a BASH script that downloads a lot of .tar source files from public sites, ie gnu.org. The intended users of the script would just like to execute the script, enter their credentials and have it complete it's task.

The command below works on RHEL6, but not RHEL5. I cannot get it to work on RHEL5, due to the older version of wget. Any ideas?

Thanks in advance

Code:

wget --user=USERNAME --ask-password http://URL

unSpawn 02-14-2013 06:05 PM

Could be something like
Code:

wget --ask-password >/dev/null 2>&1;
case $? in
 0) wget --user=USERNAME --ask-password http://URL
    ;;
 2) echo "Enter password:";
    read WGETPASS;
    wget --proxy-user=$LOGNAME --proxy-password=$WGETPASS proto://c.ol/
    ;;
esac

No idea if it works, YMMV(VM).

brandoness 02-14-2013 06:12 PM

Quote:

Originally Posted by unSpawn (Post 4891867)
Could be something like
Code:

wget --ask-password >/dev/null 2>&1;
case $? in
 0) wget --user=USERNAME --ask-password http://URL
    ;;
 2) echo "Enter password:";
    read WGETPASS;
    wget --proxy-user=$LOGNAME --proxy-password=$WGETPASS proto://c.ol/
    ;;
esac

No idea if it works, YMMV(VM).

Thanks for the reply. I already have that but not in a case loop, but just with

Code:

read -p "What is your User ID?" USER_ID;
read -p "What is your Password" PASSWORD;

Easily to reuse the environment variables in the entire script.

I found the proxy-user and proxy-password options it's just I have ! and @ in my password and they require the correct escape sequences to work.

brandoness 02-17-2013 09:27 PM

Figured I should post that I resolved the error. Using
Code:

wget -nc --proxy-user=$USER_ID --proxy-password='$PASSWORD'
worked I just had to encapsulate the password with soft (single) quotes or doing set +H at the beginning of the script works too.


All times are GMT -5. The time now is 05:37 PM.