Ubuntu Change default user when username has spaces - cmd

How would I write my command to make the command prompt reckognize the space in my username?
I'm trying to change the default user on my ubuntu system, but since my username has space in it, it creates some trouble.
I have both tried to use the back slash
C:\WINDOWS\system32>ubuntu1804 config --default-user Oskar\ B
And also use quotation marks
C:\WINDOWS\system32>ubuntu1804 config --default-user 'Oskar B'
Both of these return Error: 0x80070057 Incorrect parameter.
How do I avoid this?

Related

Request user input in bash_profile alias command

Is there anyway to stop in a bash_profile alias command and prompt for a user input? I'm fairly new to writing terminal commands.
I'm making a custom command that will take 2 inputs and edit my host files and set up vhosts for me on my local machine, at the moment i'm just passing the arguments into the command
addSite mywebsite.co.uk
But ideally I would like to be able to just run addSite, then the command stops and prompts 'Please enter the domain for your new site'.
Is this possible? If not, can someone point me in the right direction to be able to write a custom terminal command that can do this?
Thanks
You can ask for user input with read and pass a prompt with the -p flag. After the command, you specify the variable name. Then access it like any other variable.
read -p 'Please enter the domain for your new site: ' domain
echo Your domain name: $domain
EDIT: as pointed out by #tripleee in the comments, it's worth noting that this will have unintended side effects if a shell is launched from another source e.g. if you launch an executable file from Finder.

Unable to Authenticate Application Default Credentials

I am following the docs here and it says:
The simplest way for applications to authenticate to a Google Cloud Platform API service is by using Application Default Credentials (ADC). Services using ADC first search for credentials within a GOOGLE_APPLICATION_CREDENTIALS environment variable; Google Cloud recommends you set this environment variable to point to your service account key file (the .json file downloaded when you created a service account key, as explained in Set Up a Service Account.
And it says to use this command:
$ export GOOGLE_APPLICATION_CREDENTIALS=<path_to_service_account_file>
In the Google Shell, I have attempted this:
<INSERT_SOMETHING>"~$ $ export GOOGLE_APPLICATION_CREDENTIALS=</Users/grantespanet/Downloads/myfile.json>
But I get this error: -bash: syntax error near unexpected token newline
I have also tried this:
<INSERT_SOMETHING>:~$ $ export GOOGLE_APPLICATION_CREDENTIALS=/Users/grantespanet/Downloads/myfile.json
but nothing happens
I know the command is pointing to the correct file location. How can I successfully Authenticate Application Default Credentials?
The command you are executing is a variable assignment. Variable GOOGLE_APPLICATION_CREDENTIALS is given the value that follows the = sign.
The export keyword has the effect of making this variable available to child processes of the shell you are executing it from. In plain terms, it means any program you launch from the shell will have a copy of that variable (with its value) and can use it.
It is entirely normal for that command to produce no visible result or output.
The instructions you have probably require you to launch other commands after this one, which will use this value. Try performing the next steps.

Escape sequence <ESC>]0;

I am currently trying to write a script that uses expect to logon to SSH. Logging on to a server every prompt appears as [user#host]~/directory$ when I use a xterm color terminal. However, if I read the output from SSH directly with expect I see the following <ESC>]0;user#host:~/directory[user#host]~/directory$. Using export PS1="#-->" changes the result to <ESC>]0;user#host:~/directory#-->.
My question is: What does the sequence <ESC>]0;do? And which class of terminals does it belong to? I could not find it for neither VT52 nor VT100.
by default, the label of each tab is the name of the job that's running in that session. some systems are configured to augment this with additional information such as the hostname you're logged in to or your current directory; this is done by sending a special code of:
ESC]0;<string>^G
such as, ESC]0;david#Scott:~^G, would put "david#Scott:~" in my tab title
this is referred to as the XTERM hardstatus hack.

how to create a user in oracle using SQL*PLUS by running a script from txt file that will prompt me for 2 parameters (username, password)

I have a question about creating users in Oracle using SQL*PLUS. But what I want to do is write the syntax in a txt file first (script) then when I run the script by calling it using the # or by copy/past it should prompt me for two parameters (user name and a password). I searched through the web and read 2 books and I still can't find the right syntax.
You can use the ACCEPT command to prompt the user for an input (but it's not really necessary if you use substitution variables that are prefixed with the & character.
Details are in the manual:
http://docs.oracle.com/cd/B28359_01/server.111/b31189/ch5.htm#CACIFHGB
If you want to customize the message displayed to the user when entering the value, you can use the ACCEPT command.
Again details are in the manual:
http://docs.oracle.com/cd/B28359_01/server.111/b31189/ch12005.htm#BACGJIHF

Sqlplus login error when using bash variables: SP2-0306: Invalid option

I have a bash script that connects to an oracle 10g database.
In a first step it takes some variables from a "config" file with the following command
. /path/to/my/configfile.ini
In the config file there are some variables:
export USRID=myUser
export USRID_PASS=myPassword
export USR_PASS="$USRID/$USRID_PASS#myDatabase"
Then it actually connects through sqlplus using the command:
sqlplus -s $usr_pass
Terrible Security and Design issues aside (this script has been around for 5 years). This is actually doing its job in one of our UNIX servers, but not in another.
When I run the script with bash -x, I can see that the command expanded to:
sqlplus -s myUser/myPassword#myDatabase
...which should do fine (and is actually working in one server), but the response in the failing server is:
ERROR: ORA-01017: invalid username/password; logon denied
SP2-0306: Invalid option.
Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
where ::= [/][#] |
SP2-0306: Invalid option.
I'm guessing it has to do more with bash than with oracle, but I'm no bash expert. Is there some configuration or detail I'm missing?
EDIT:
Trying to pin down the problem a bit more, I'm now running two versions of the script in a third development server, and in different tests, the login works if i do it with:
sqlplus -s $usrid/$usrid_pass#myDatabase
but not when i try:
sqlplus -s $usr_pass
So its a bit annoying.
Besides that, i'll have to check on te config file synchronization process... I'll let you know when i get to something new. Thanks everybody.
The message is pretty clear:
you've successfully contacted a database
the credentials supplied are wrong
This indicates there isn't really anything wrong with your client configuration.
So, that leaves you with
the user/pw combination is wrong
you've not contacted the database you think you have
Possibilites:
Make sure you can connect with the credentials supplied from the command line.
Use tnsping mydatabase to check the host and instance you're contacting, verify it's correct. Output from this command should tell you the host, port, and instance/service you're connecting to. If it's wrong, check the tnsnames.ora file for this alias.
As #OMG Ponies suggests, if you're using 11g, make sure the case in your passwords is correct
This worked for me: connect user/"password"
I think if the password contains special characters like '#' we need to use "" for the password.
Daft question, but are you sure you are using the bash shell on both unix servers ?
I'd try replacing
export USR_PASS="$USRID/$USRID_PASS#myDatabase"
with
export USR_PASS="${USRID}/${USRID_PASS}#myDatabase"
to make sure the variables get interpreted correctly
As a final, exotic though, does the password contain any characters other than basic alpha-numeric and punctuation. Because 10g isn't case sensitive, a lowercase password gets converted to uppercase, which can cause odd effects with things like accented characters
I solved this problem on my mac machine by changing the shell to 'sh' from 'bash'. Everything just worked smooth then.
Thanks to the original reporter of the problem who explained with a good hint.

Resources