0

I want to connect to a server through AtlasVPN automatically.

@user: $ atlasvpn connect
1 - Standard
2 - Streaming
3 - SafeSwap
4 - MultiHop
*(IT IS NOT ANOTHER LINE)* Enter a number corresponding to the desired category: 1
1 - Netherlands - Amsterdam
2 - United States - New York
3 - Hong Kong - Hong Kong
4 - United States - Dallas
5 - United States - Los Angeles
6 - Singapore - Singapore
7 - Finland - Helsinki
8 - Norway - Oslo
9 - New Zealand - Auckland
10 - Argentina - Buenos Aires
11 - Hungary - Budapest
12 - Denmark - Copenhagen
13 - Germany - Frankfurt
14 - Bulgaria - Sofia
15 - Sweden - Stockholm
16 - United States - New Jersey
17 - Netherlands - Amsterdam
18 - UAE - Dubai
19 - Serbia - Belgrade
20 - Japan - Tokyo
21 - United Kingdom - London
22 - United Kingdom - Manchester
23 - France - Paris
24 - Poland - Warsaw
25 - Latvia - Riga
26 - Ireland - Dublin
27 - Estonia - Tallinn
28 - Czech Republic - Prague
29 - United States - Las Vegas
30 - Slovakia - Bratislava
31 - Austria - Vienna
32 - United Kingdom - London
33 - Italy - Milan
34 - Spain - Madrid
35 - Canada - Montreal
36 - Turkey - Istanbul
37 - Brazil - Sao Paulo
38 - United States - Miami
39 - Mexico - Mexico City
40 - South Africa - Johannesburg
41 - United States - Phoenix
42 - Israel - Tel Aviv
43 - Chile - Santiago
44 - Thailand - Bangkok
45 - Belgium - Brussels
46 - Albania - Tirana
47 - Taiwan - Taipei
48 - Romania - Bucharest
49 - Switzerland - Zürich
50 - Portugal - Lisbon
51 - Australia - Sydney
*(IT IS NOT ANOTHER LINE)* Enter a number corresponding to the desired server: 38
You have successfully connected to United States - Miami.
@user:
  1. This type of code does not work:
#!/bin/bash
atlasvpn connect
1
38

Because "Enter a number corresponding to the desired category:" and "Enter a number corresponding to the desired server:" are in the same command-line.

enter image description here

karel
  • 110,292
  • 102
  • 269
  • 299
  • Does this answer your question? [How to solve "permission denied" when using sudo with redirection in Bash?](https://askubuntu.com/questions/230476/how-to-solve-permission-denied-when-using-sudo-with-redirection-in-bash) – guiverc May 21 '23 at 01:15
  • No, it does not have to do with the question. – Calma Flamma May 21 '23 at 01:21
  • 1
    This might work: `echo -e '1\n38\n' | atlasvpn connect` – Cyrus May 21 '23 at 01:41
  • 1
    **Welcome to the Ask Ubuntu community.** Your question doesn't appear to be related to the Ubuntu OS. You'll likely be better served by working with the [Unix & Linux community, as this is a common bash question](https://unix.stackexchange.com/). – richbl May 21 '23 at 04:12
  • 1
    For these types of tasks, look into `expect` scripts. – Artur Meinild May 21 '23 at 07:52

1 Answers1

-1

I tried it like this:

#/bin/env expect

spawn atlasvpn connect
expect {
    "Enter a number corresponding to the desired category:\r" {
        send "1\r"
        expect {
            "Enter a number corresponding to the desired server:\r" {
                send "10\r"
                interact
            }
        }
    }
}

But it´s doesnt work. It asks for the first value and then times out.