Score:0

Help me to develop a .sh script to start a simple task

na flag

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

guiverc avatar
cn flag
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)
Calma Flamma avatar
na flag
No, it does not have to do with the question.
Cyrus avatar
cn flag
This might work: `echo -e '1\n38\n' | atlasvpn connect`
ec flag
**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/).
Artur Meinild avatar
vn flag
For these types of tasks, look into `expect` scripts.
Score:-1
md flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.