1

I have created a bash script login.sh. I want it to open the browser and login to my Gmail account.

I tried using the following command to open the browser with www.gmail.com.

xdg-open http://gmail.com

It opens Gmail home page perfectly.

But I don't know how to pass the username and password for login to Gmail from the bash script.

Is it possible to open the browser and login to Gmail from a script?

2 Answers 2

1

Gmail does not allow logging in from the url(or basic HTTP auth in general), my best guess would be to use something like the selenium webdriver to script the form filling as well as clicking the login button.

1
  • I already think about that, I just want to know without using selenium webdriver is it possible or not. Thanks May 29, 2014 at 8:10
0

You can script the mouse movements, clicks and keyboard. More detailed information here. There is also a demonstration here and you can find plenty of more online.

A minimal example to get the idea is:

xdotool mousemove 999 999; sleep .1 # coordinates of username field
xdotool click 1; sleep .1
xdotool type; sleep .1 # type your username, and then repeat for the password and login button

I used sleep in case it is too fast for the browser/computer; you can remove it or augment its values. Finally, you can get your mouse's coordinates with

xdotool getmouselocation
1
  • can you please elaborate it with example, so i can easily understood it May 29, 2014 at 9:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .