Score:1

How can I write in a shell setup with a script?

in flag

I want to automate my installation of teamviewer. I can set up teamviewer using the command teamviewer setup which runs in the gnome shell and asks me for the credentials. I would like to be able to automate this in a script and not have to enter the credentials by hand.

I have already use command like:

$ printf "xxxxx\nxxxx" | teamviewer setup

But didn't work.

Any solutions ?

teamviewer setup command

Artur Meinild avatar
vn flag
You really need to explain in more detail what it is you want to achieve, it's not clear from your question. What exactly does the setup script need to do?
laoduille avatar
in flag
Sorry I'm not good in English. I want to automate my installation of teamviewer. I can set up teamviewer using the command "$ teamviewer setup" which runs in the gnome shell and asks me for the credentials. I would like to be able to automate this in a script and not have to enter the credentials by hand.
raj avatar
cn flag
raj
Is `teamviewer setup` command asking you for credentials on the terminal or via some GUI window?
laoduille avatar
in flag
On the terminal.
raj avatar
cn flag
raj
@laoduille Then you can use `expect` to automate this. See my recent answer to a very similar question: https://askubuntu.com/questions/1360835/accept-options-when-installing-java-in-terminal/1361425#1361425
laoduille avatar
in flag
I think this is the solution to my problem. I'm going to look this way. I keep informed if it worked. Thanks!
Score:1
in flag

My problem was solved by the tool advised by raj. Thanks to him ! This tool is "Expect". https://linux.die.net/man/1/expect

Expect is a program that "talks" to other interactive programs according to a script. Following the script, Expect knows what can be expected from a program and what the correct response should be. An interpreted language provides branching and high-level control structures to direct the dialogue. In addition, the user can take control and interact directly when desired, afterward returning control to the script.

Example: (In my case)

#!/usr/bin/expect

spawn teamviewer setup   
expect "username:"          
send "xxxxxx\r"      
expect "password:"       
send "xxxxxx\r"     
wait 
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.