bash script to login to webpage

48,386

Solution 1

Easiest way to bash login:

wget --save-cookies cookies.txt --keep-session-cookies --post-data="username=foo&password=bar" "http://some.site/login.php"

Although some websites may have some restrictions to login like this.

Solution 2

You can try this even in Yahoo prompt bash ... you will get a login accepted

curl --user name:password http://mail.yahoo.com -v 

curl is the way to do it in bash.

Share:
48,386

Related videos on Youtube

Ntc
Author by

Ntc

Updated on September 18, 2022

Comments

  • Ntc
    Ntc over 1 year

    I am trying to login into this page but I cannot for the life of me get it to work. I have to login to this site when i connect to my school's wifi in order to start a session.

    So far ive tried to use bash and cUrl to achieve this but have only achieved to give myself a headache. will cUrl work or am I on the wrong track? Any help is greatly appreciated!

    Thanks,

    N

    Here's what i tried:

    curl --cookie-jar cjar --output /dev/null http://campus.fsu.edu/webapps/login/
    
    curl --cookie cjar --cookie-jar cjar \
        --data 'username=foo' \
        --data 'password=bar' \
        --data 'service=http://campus.fsu.edu/webapps/login/' \
        --data 'loginurl=http://campus.fsu.edu/webapps/login/bb_bb60/logincas.jsp' \
        --location \
        --output ~/loginresult.html \
            http://campus.fsu.edu/webapps/login/
    
    • Daniel W.
      Daniel W. over 11 years
      Could you post the code you tried to use to login to that webpage? Also I think bash isn't the way you wanna do this I'm not even sure if there's a way to do this in bash. Sounds like a job for Perl or JavaScript maybe? I'm just starting to learn the basics of programming myself though.