Skip to content

Instantly share code, notes, and snippets.

@pourmand1376
Last active May 1, 2024 07:03
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pourmand1376/965625a56c9e8ba4a82cd6f7dd98ed80 to your computer and use it in GitHub Desktop.
Save pourmand1376/965625a56c9e8ba4a82cd6f7dd98ed80 to your computer and use it in GitHub Desktop.
Sharif Login
function sharif_login
{
curl -d "username=$1&password=$2" -X POST "https://net2.sharif.edu/login" > /dev/null
curl -s https://net2.sharif.edu/status | grep -o '<td>.*</td>'
sleep 1s # To See login status
}
function sharif_ip
{
# from ping net2.sharif.edu
# this is written since sometimes DNS server doesn't work!
curl -d "username=$1&password=$2" -X POST -k "https://172.17.1.214/login" > /dev/null
curl -sk https://172.17.1.214/status | grep -o '<td>.*</td>'
sleep 1s # To See login status
}
function sharif_logout
{
curl -d "username=test&password=test" -X POST "https://net2.sharif.edu/logout"
sleep 1s
}
sharif_login1="sharif_login YourUsername Yourpassword"
sharif_ip1="sharif_ip YourUsername YourPassword"
alias 1="sharif_login1 && exit"
alias ۱="1"
@pourmand1376
Copy link
Author

pourmand1376 commented May 22, 2022

Just add these lines to your .bashrc or .zshrc and you are good to go.

Also, don't forget to put your username and password instead of YourUsername and YourPassword.

To Login, you can type, 1 or ‍۱ or sharif_login1. You can also type sharif_logout to logout.

This script is also useful when you are having problem with DNS. Just type ip1 or sharif_ip1 and it will try to login when DNS is problematic.

@pourmand1376
Copy link
Author

pourmand1376 commented Aug 20, 2022

If you are on Windows, just use:

C:\Windows\System32\curl.exe -d "username=YourUserName&password=YourPassword" -X POST "https://net2.sharif.edu/login"

You can also edit $profile file and add a function like this there.

function sharif_login
{
C:\Windows\System32\curl.exe -d "username=YourUserName&password=YourPassword" -X POST "https://net2.sharif.edu/login"
}
set-alias a1        sharif_login

Note: It is better to just install wsl.

@SaeedForoutan
Copy link

SaeedForoutan commented Feb 23, 2024

Thanks for this beneficial code! I found it really helpful. I have a suggestion to enhance it further – consider putting the sharif_login1 directly in an alias and removing the exit at the end. Here's a simplified version:

alias 1="sharif_login YourUsername Yourpassword"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment