Unable to run oracle query using bash script - linux

I have created a script in linux with content-
sqlplus -silent test/test123#XYZ <<SQL_QUERY
select * from test.persons;
SQL_QUERY
Here-
test - username
test#123 - password
XYZ - SID Name
But wen I am running this I am getting error -
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
SP2-0306: Invalid option.
Can anyone please help me with this issue ?
Thanks in advance!

Based on this:
test - username
test#123 - password
XYZ - SID Name
I am guessing that you actually tried to run:
sqlplus -silent test/test#123#XYZ
which is why SQL*Plus would have complained because of the 2 "#".
Try putting your password in double quotes to avoid this. An even better way is to put the password in a connection wallet, so its never coded in the script. See this post for how to do this
https://connor-mcdonald.com/2015/09/21/connection-shortcuts-with-a-wallet/

Related

Postman api key not valid in gitlab-ci

In my gitbal-ci.yml using the below instruction:
curl -s https://api.getpostman.com/environments?apikey=${POSTMAN_APIKEY}
I receive the error:
error: could not load environment
Invalid API Key. Every request requires a valid API Key to be sent.
The variable POSTMAN_APIKEY is correctly set in my gitlab Setting CI/CD as POSTMAN_API with the key generated in my postman account.
If I try to execute the curl command via shell, it works perfectly.
What's wrong? thanks
I think you should use double quotes "curl -s https://api.getpostman.com/environments?apikey=${POSTMAN_APIKEY}" because of variable expansion in bash. But variable name must be the same in Setting CI/CD, so POSTMAN_APIKEY in both places. If you set variable as protected, be sure to flag your branch as protected as well.

onelogin aws cli returns bad request

I'm trying to setup AWS CLI login via OneLogin - but it doesn't seem to work.
I created the onelogin.sdk.properties file as follows:
onelogin.sdk.client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxx
onelogin.sdk.client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxx
onelogin.sdk.region=us
onelogin.sdk.ip=
I'm running the below command from the same directory where the above properties file resides:
java -jar onelogin-aws-cli.jar --appid 123456 --subdomain mycompany --username myusername --region us-east-1 --profile onelogin
This prompts me for the password and after I enter it, I get the following error:
Exception in thread "main" OAuthProblemException{error='bad request', description='bad request', uri='null', state='400', scope='null', redirectUri='null', responseStatus=400, parameters={}}
at org.apache.oltu.oauth2.common.exception.OAuthProblemException.error(OAuthProblemException.java:59)
at org.apache.oltu.oauth2.client.validator.OAuthClientValidator.validateErrorResponse(OAuthClientValidator.java:63)
at org.apache.oltu.oauth2.client.validator.OAuthClientValidator.validate(OAuthClientValidator.java:48)
at org.apache.oltu.oauth2.client.response.OAuthClientResponse.validate(OAuthClientResponse.java:127)
at com.onelogin.sdk.conn.OneloginOAuthJSONResourceResponse.init(OneloginOAuthJSONResourceResponse.java:31)
at org.apache.oltu.oauth2.client.response.OAuthClientResponse.init(OAuthClientResponse.java:101)
at org.apache.oltu.oauth2.client.response.OAuthClientResponse.init(OAuthClientResponse.java:120)
at org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory.createCustomResponse(OAuthClientResponseFactory.java:82)
at com.onelogin.sdk.conn.OneloginURLConnectionClient.execute(OneloginURLConnectionClient.java:75)
at org.apache.oltu.oauth2.client.OAuthClient.resource(OAuthClient.java:81)
at com.onelogin.sdk.conn.Client.getSAMLAssertion(Client.java:2238)
at com.onelogin.aws.assume.role.cli.OneloginAWSCLI.getSamlResponse(OneloginAWSCLI.java:437)
at com.onelogin.aws.assume.role.cli.OneloginAWSCLI.main(OneloginAWSCLI.java:256)
I know for a fact that my onelogin.sdk.properties is correct, because intentionally setting incorrect client_id/client_secret or changing the region to eu makes the application fail with another error (error='Unauthorized')
What might be the problem?
Is there a debug switch I can use to help me understand what's going on?
Thanks,
Yosi
The problem was me using the username in incorrect format (needed the domain suffix - e.g. myusername#mydomain.com)

Not able to connect postgresql with odoo

I configured odoo in aws ec2 and connecting Postgresql from rds when I run the command ./odoo-bin --config=/etc/odoo.conf and try to access from a browser, I'm getting the following error:
ERROR odoo_db odoo.modules.loading: Database odoo_db not initialized, you can force it with `-i base`
File "/opt/odoo/odoo/odoo/modules/registry.py", line 176, in __getitem__
return self.models[model_name]
KeyError: 'ir.http' - - -
and also I'm getting this error as well:
STATEMENT: SELECT latest_version FROM ir_module_module WHERE name='base'
ERROR odoo_db odoo.sql_db: bad query: SELECT latest_version FROM ir_module_module WHERE name='base'
ERROR: relation "ir_module_module" does not exist
In command line run:
./odoo-bin --addons-path=addons --database=odoo --db_user=odoo --db_password=odoo --db_host=localhost --db_port=5432 -i INIT
explicitly give db name, user and password, "-i INIT" option initialises the odoo database
The first glance issue is though the DB has created in Postgres but it has not the required odoo related setup records i.e. base setup. You can verify by directly accessing the DB and see the number of tables or browsing some tables.
It happens sometimes that you create the DB [specifically giving similar DB names as you have already created before and deleted later [its dropped from PG but still has traces in session or DB location path], it will not get initialized properly.
Solution:
Create sample DB with different name initial 4 characters different completely and check
Initialize the DB from odoo.conf file add db_name = < Your DB Name > {for experiment purpose put completely different name} and restart odoo services and check
Hope it will help. Njoy troubleshooting!
First do what #FaisalAnsari says in here (what I reference below):
*
Go to RDS and create a database in PostgreSQL and configure the
server.conf file as the given below.
;This is the password that allows database operations:
;admin_passwd = admin
db_host = rds_endpoint (after creating database you will get
rds_endpoint)
db_port = False
db_user = "user name which is created by you to the database"
db_password = "password which is created"
;addons_path =
/home/deadpool/workspace/odoo_13_community/custom_addons,
/home/deadpool/workspace/odoo_13_community/custom_addons
Then go to the command line and do the following.
Stop your odoo instance
~$ service odoo stop
Enable command line for the user odoo
~$ chsh -s /bin/bash odoo
execute odoo from command line as user odoo
~$ runuser -l odoo -c "odoo -i base -d YourRDSDatabase --db_host YourAmazonRDSHost.Address.rds.amazonaws.com -r YourRDSDatabaseUserName -w YourRDSDatabasePassword --stop-after-init"
After the initialization finished, start odoo service
~$ service odoo start
Troubleshooting :
if odoo doesn't start correctly make sure that the database user in your RDS instance have privileges at least on the database you are using.
~$ psql --host=YourAmazonRDSHost.Address.rds.amazonaws.com --port=5432 --username=YourRDSDatabaseUserName --password --dbname=YourRDSDatabase
and when you are inside postgresql type the following:
~$ grant all privileges on database YourRDSDatabase to YourRDSDatabaseUserName;
~$ \q
and try again from step 3.
Hope that Helps!!

error running `sqlplus` as user `oracle`

Im trying to run sqlplus from user oracle in linux, but i only get the following error.
Error 6 initializing SQL*Plus
SP2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
[ sqlplus ] completed with error code: 1
I have tried to run ./oracle_env.sh as user oracle and have tried it as user root as-well, but when I run the sqlplus / as sysdba command logged in as user oracle I get the above message.
Did I miss something, am I on completely the wrong track?
Here is a full output that I used/got.
`su - oracle
cd /u01/app/oracle/product/11.2.0/xe/bin
./oracle_env.sh
sqlplus / as sysdba`
If /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh sets your ORACLE_HOME, and ORACLE_SID environment variables, you need to "source" it invoking it in the current environment) using the "dot" prefix:
. ./oracle_env.sh
In any case, looks like your environment variables (including LD_LIBRARY_PATH) may not be set correctly.

Unable to query mongolab mongodb

I'm using the Nodejitsu and their packaged Mongolab MongoDB database. I ran the command jitsu databases get myDB and I got instructions on how to connect via mongo CLI. The out put of that command has a line that says the following:
help: Connect with the `mongo` cli client:
help:
$ mongo ds039267.mongolab.com:39267/nodejitsu_xxxxxx_nodejitsudb8577296358 -u nodejitsu_xxxxxx -p mypassword
NOTE: This is the first time I am connecting to this instance via the CLI. I only created the database name through jitsu databases create…
I am using Mongo Shell version 1.8.3. I connected to my instance of MongoDB. I tried running the command: show dbs and I got:
uncaught exception: listDatabases failed:{ "ok" : 0, "errmsg" : "unauthorized" }
I am using Mongoose and I have a model called Post. I tried to run: db.post.find() in the CLI, I got:
error: { "$err" : "not authorized for query on hotel.post", "code" : 16550 }
What does this mean? Am I not authorized; I thought I connected successfully?
Updated
I upgraded my mongo shell to the latest, 2.4.x version and still I'm getting this problem. Anyone have any experience with nodejitsu & mongolab?
MongoLab creates databases that require an authenticated user to access. When you connect with the Shell, you will need to provide the UserName and Password to the shell command. Docs are here.
mongo --username Mark --password something
You will need that Username/Password combination to be configured within mongoose as well. The Mongoose docs have details on the possible ways to do this.
Note that you are using a very old shell. 1.8.3 is about 4 versions back from the current 2.4.* line. This is not directly related to your problem, but it's definitely something you should rectify going forward.
Inside the mongo shell try to authenticate once again:
db.auth('yourUsername','yourPassword');
One possible error could be like me : Using special chars in the password breaks the URI!
The generated password was
X/apm~nq5JaJ,5
So OBVIOUSLY, the / broke the request and I got :
MongoError: not authorized for query on apm~nq5JaJ.system.indexes
You can try to include at the end of your URI: ?authMode=scram-sha1

Resources