You are not logged in.

#1 2016-07-02 18:03:46

whiskeytango3000
Member
Registered: 2016-06-19
Posts: 5

How to store user input (bash)

The first time a user runs this it prompts for their Skype username and password. Initially I sought to store that user input ($skypeuser and $skypepass) in SKYPEUSR and SKYPEPWD so the user only has to enter his credentials once. But I am not sure how to do this. According to the post linked below I should store the input in a file on the user's disk, then have the script read it. What other options are available? Thank you!
http://askubuntu.com/questions/52212/wh … y-a-script

#!/usr/bin/env bash

SKYPEUSR=()
SKYPEPWD=()
skypeLoginAuth() {
  if [[ -z ${SKYPEUSR} && -z ${SKYPEPWD} ]]; then
  echo -e "\nSkype name and password are unset.\nType your Skype username and hit Enter"
  read -p $'\e[1;36m>>> ' skypeuser
  echo -e "\nType your Skype password and hit Enter"
  read -p $'\e[1;36m>>> ' skypepass
  skypeLogin
    else
      skypeLogin
  fi
}

skypeLogin() {
  echo -e "\nLaunching Skype...\n"
  echo $skypeuser $skypepass | nohup skype --pipelogin >/dev/null 2>&1 &
}

Offline

#2 2016-07-03 15:51:49

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: How to store user input (bash)

What other option do you need? Do you have anything specific in mind?

Offline

#3 2016-07-03 15:58:32

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,534
Website

Re: How to store user input (bash)

Do these data need to be secured/encrypted or can they be stored in plain text?  If plain text will work, just write them to a file, then instead of echoing the variables to the skype pipe, just redirect input from the file:

skype --whatever flags < ~/.skype_credentials

If you want to avoid any extra file and plain-text is still safe, you can have a self modifying script:

skype_user=""
skype_pass=""

if [[ $skype_user == "" ]]; then
   read -p "user name: " skype_user
   sed -i 's/^skype_user=""/skype_user="'$skype_user'"/' $0
fi
if [[ $skype_pass == "" ]]; then
   read -p "password: " skype_pass
   sed -i 's/^skype_pass=""/skype_pass="'$skype_pass'"/' $0
fi

echo $skype_user $skype_pass | nohup ...

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB