Can you use pmrep createConnection command with parameter in Password - informatica

Is there a way to create a connection in Informatica from the pmrep command line tool with the "Use Parameter in Password" option? This is simple from the GUI I need to automate the process via a script.
Here is the command I am running:
pmrep createconnection -s Oracle -n DummyConn -u $ParamTEST_DB_USERNAME -p $ParamTEST_DB_PASSWORD -c TEST123 -l US-ASCII
I have tried the following without luck:
-p option which simply treats the password as a normal
-P option which complains there is no environment variable by that name
-k with "Use Parameter In Password"=true

-P is the correct way to go for you.
But before running the command you need to run these 2 commands :
export $ParamTEST_DB_USERNAME= << Your Username >>
export $ParamTEST_DB_PASSWORD= << Password encrypted with pmpasswd >>
The rest of your command seems fine

Related

Aws ec2 user data script not working on start up

I am trying to run a script on my EC2 at startup, with an image I created that runs ubuntu.
However, the script is failing although when I connect through ssh and run the script it is working.
My user data is:
#!/bin/bash
echo '
#!/bin/bash
sleep 30
sudo apt-get update
cd /etc/apache2/sites-available
sudo sed -i 's/oldurl/newurl/g' 000-default.conf
sudo sed -i 's/oldurl/newurl/g' 000-default.conf
sudo certbot --apache -d url1 -d url2
sudo systemctl restart apache2' > init-ssl.sh
sleep 2 & init-ssl.sh
I stopped my instance and changed my user data to something simple like:
#!/bin/bash
echo 'work' > try1.txt
I didn't see an error but I also didn't see my new try1.txt file.
A script passed via User Data will only be executed on the first boot of the instance. (Actually, the first boot per Instance ID.)
If you want to debug the script, the log file is available in:
/var/log/cloud-init-output.log
Your attempt to redirect to a file with echo ' ... ' >init-ssl.sh is being thwarted by the fact that the script also contains a single quote ('), which is closing the echo early. You should use different quotes to avoid this happening. Or, as #Mornor points out, simply run the script directly. If you want to sleep for a bit up-front, then just put the sleep() at the start of the script.

Run a bash script from another user with Django

this is my first Django project, I apologies if I say some nonsense
To start a game server, I have to login with ssh as the user running the server, then type./server start to start it.
I want to be able to run this command from a webapp.
As of now, I've managed to do this on Django.
What I want to do is that when I press the "Start" button, this commands run on the server side:
su - gameuser -c '/home/gameuser/server start' > /dev/null 2>&1
The problem I'm facing is that I don't know how to login as the gameuser since I'm not a running the webapp as a sudo user.
How can I approach this problem?
Thanks in advance :D
You can configure ssh keys for webapp user to login as gameuser without entering password and execute:
ssh gameuser#localhost -c '/home/gameuser/server start' > /dev/null 2>&1
You can configure webuser to execute specified command with sudo (sudoers file is pretty flexible)
add the following to /etc/sudoers
webapp ALL = (gameuser) ALL
and then you can run the following as webapp user
sudo su - gameuser -c '/home/gameuser/server start' > /dev/null 2>&1
You can improve the second option, allowing webapp user to execute only specific command as gameuser, for example write start script ( /home/gameuser/server_start.sh ) and add to the /etc/sudoers:
webapp ALL = (gameuser) /home/gameuser/server_start.sh
and again you will able to run the following in more secure way.
sudo su -gameuser -c /home/gameuser/server_start.sh

compute engine startup script can't execute as a non-root user

Boiling my issue down to the simplest case, I'm using Compute Engine with the following startup-script:
#! /bin/bash
sudo useradd -m drupal
su drupal
cd /home/drupal
touch test.txt
I can confirm the drupal user exists after this command, so does the test file. However I expect the owner of the test file to be 'drupal' (hence the su). However, when I use this as a startup script I can still confirm ROOT is the owner of the file:
meaning my
su drupal
did not work. sudo su drupal also does not make any difference. I'm using Google Container OS, but same happens on a Debian 8 image.
sudo su is not a command run within a shell -- it starts a new shell.
That new shell is no longer running your script, and the old shell that is running the script waits for the new one to exit before it continues.
The sudo su command will start a new shell. The old shell waits for the old one to exit and continues executing the rest of the code.
Your script is running in the 'old' shell, which means these commands:
cd /home/drupal
touch test.txt
are still executed as root and thus the owner of these files is root as well.
You can modify your script to this:
#! /bin/bash
sudo useradd -m drupal
sudo -u drupal bash -c 'cd ~/; touch text2.txt'
and it should work.
The -u flag executes the command as the user specified, in this case 'drupal'
I wrote some stuff underneath - but looks like this should work:
how to run script as another user without password
The other option would be to ssh into your own machine as the other user, you can use sshpass to send the password, or get your own public key.
When I test a similar script:
su [my username]
touch test.txt
It actually logs in as me, and doesn't finish until I ctrl-d
Further testing reveals that the only way to own the file is if I invoke the script from the shell, ie:
su me
touch test.txt
./test2.sh
test2.sh:
touch test2.txt
gives both files to root, even if I own both scripts.
This follows that everything YOU do is yours, you can't make something for someone else.

linux running command as root from c code that run as normal user

I have a c++ code and I need to running from it a command to adjust the system time.
so I thought using system("su root -c date hh:mm") command from my c++ code.
The problem is that when I write 'su root -c date hh:mm' in the terminal its requires password after, and how can I pass the password to the system command in one line?
or another solution...
Thanks!
A workaround is to modify the sudoers file and remove the requirement of a password from your user ID for a particular script to have sudo privileges.
Enter sudo visudo
After this, add the details in the following manner.
username ALL=(ALL) NOPASSWD: /path/to/script
Another method would be to pipe the password as input to the sudo command. I don't recommend this, as you would be entering your password as plain text. You could use a variable to store the password, and then access it, but it still isn't a secure method. You could run the command as
echo $PASSWORD | sudo ./a.out

How to run print command lpr -p programmatically throgh root privilage in Qt

I want to run print command lpr -p programmatically through root privilege in Qt. Actually I want to print the pdf file using these command. This command is working through terminal but not through programmatically.
Thanks in advance.
you can run commands that need root privilege by running :
echo myPass | sudo -S lpr -p
Although it's not a good idea to echo your password in shell but you can do it in Qt via Qprocess like :
QProcess process1;
QProcess process2;
process1.setStandardOutputProcess(&process2);
process1.start("echo myPass");
process2.start("sudo -S lpr -p");
process2.setProcessChannelMode(QProcess::ForwardedChannels);
process2.waitForFinished(3000);