Unable to run sqlplus commands from jenkins - unix

I have a shell script at Unix Server which contain sqlplus commands to do some validation.and I can run script using putty and see required result.In Unix server I have set up Oracle path and Library path in .bash_profile file. So when I start putty , it get loaded and can understand sqlplus command.
Now Challenge is
when I call that shell script from Jenkins(Windows node) then I get error "sqlplus command not found". Here I call .bash_profile file first then my shell script which have sqlplus commands.
Please help.

Set up the PATH as an environment variable in your Jenkins job definition. More details here:
How to set up environment variables in Jenkins

Related

Execute wincsp command line arguments from within R

I have some command line batch code which I can run in my windows command prompt just fine. I'm basically pushing a local file text file to a remote server using WinSCP command line arguments - https://winscp.net/eng/docs/commandline. These are the commands I use, in order:
to open up winscp command line:
winscp
then to open connection to my server through ssh:
open sftp://myUserName:myPassword#theRemoteServer.net
upload file to remote server:
put directoryMyLocalFileIsIn\fileToUpload.csv /locationOnRemoteServer/whatToNameFileOnRemoteServer.csv
then close connection:
close
This all works fine. But, I want to run this all from within RStudio.. My issue -
after I run:
shell.exec("winscp")
I can see the winscp shell is opened up. But when I try and run my next commands like these:
shell.exec("open sftp://myUserName:myPassword#theRemoteServer.net")
It just doesnt run in that winscp shell that opened up.. I've also used all sorts of combinations of R commands like shell, system2 and shell.
Again, I can open up the winscp shell successfully from within R. But I cant figure out how to then run commands in that shell. Anyone know how to do this?
Thank you.
You need to call WinSCP and specify all commands using a single call from R. The best way to do this is to save your WinSCP commands in a single text file, e.g. myscript.txt:
open sftp://myUserName:myPassword#theRemoteServer.net
put directoryMyLocalFileIsIn\fileToUpload.csv /locationOnRemoteServer/whatToNameFileOnRemoteServer
exit
Then, from the command line, you can call WinSCP as follows (see the WinSCP documentation):
winscp.com /script=myscript.txt
(you might need to specify the exact path for WinSCP and myscript.txt)
Finally, to accomplish this from R, use the system2 command as follows:
system2(
"winscp.com",
args = c("/script=myscript.txt"))
Again, you might need to specify the paths to winscp.com and myscript.txt.

SSH key not found when using system() to send git commands to command prompt in windows

I am trying to execute git commands with a public SSH key using the system() function in R (on Windows 7 64 bit). When I try to execute a git command I get the following error:
ssh_askpass: exec(rpostback-askpass): No such file or directory
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I can run the exact same command on the command prompt and it works. I can also run the exact same command on the git bash shell and it works. I am not sure why cmd can't find the key when run from R using the system() command. Is there a way to specify the key location for the command prompt used by the system() command?
Update:
An example call that won't work:
system("git push --set-upstream git#gitlab.mygit.com:MyGroup/testGitlab.git master")
also
system("git clone git#gitlab.mygit.com:MyGroup/gitLabTest.git")
Both of these calls get the same error above.
Update 2: It appears that the ssh keys are not visible from R using list.files()
> list.files("C:/Users/Me/Documents/.ssh/", all.files = TRUE)
[1] "." ".."
I have verified that there are multiple ssh keys in this directory which are visible from the git bash shell using ls -a.
As it turns out, on my Windows system (7, 64 bit), when creating SSH keys with the git bash shell they were saved to "C:\Users\MyAcount\.ssh". However, the cmd.exe called by system() in R was looking in "C:\Users\MyAccount\Documents\.ssh".
For some reason, when using the cmd prompt called directly from the OS it looks in the same .ssh directory as the bash shell. Go Figure. Windows, I don't think I will ever understand you. Hope this helps someone out there.

Jar file run on a server background with close putty session

I have tried the run spring boot jar file using putty. but the problem is after closed the putty session service was stopped.
then i tried up the jar file with following command. its working fine .
**nohup java -jar /web/server.jar **
You should avoid using nohup as it will just disassociate your terminal and the process. Instead, use the following command to run your process as a service.
sudo ln -s /path/to/your-spring-boot-app.jar /etc/init.d/your-spring-boot-app
This command creates a symbolic link to your JAR file. Which then, you can run as a service using the command sudo service your-spring-boot-app start. This will write console log to /var/log/your-spring-boot-app.log
Moreover, you can configure spring-boot/application.properties to write console logs at your specified location using logging.path=path-to-your-log-directoryor logging.file=path-to-your-log-file.txt. Also, it may be worth noting that logging.file takes priority over logging.path

To execute shell script from Sql prompt

I have one shell script test.sh that displays 'WELCOME' and kept in unix server /home/xxx/
Now, I want to execute this from Sql prompt.
I tried with some code with sys priviledge.but could work and getting error like ORA-29540: class does not exist
and I think there is error while executing shell command.
Here, I have created all objects in the database.
can any one help me on this please ?.
So, what I understand is you need to execute a shell script from sql prompt.
From the SQL*Plus prompt, do !sh script_name. (! is used to temporarily exit out of SQL*Plus and execute a shell command)
I created a sample.sh file on the home directory and it contains echo "welcome";
I started SQL*Plus and did
SQL> !sh sample.sh
The output is welcome
Also, when you get an ORA error, it is generally an Oracle error.

db2 command not found in unix

I am trying to execute a simple db2 command in Linux command prompt. but Linux command prompt is not recognizing the command it is giving - bash db2 command not found. but db2 is installed in the Linux machine.
command I am trying to execute from Linux command line processor is db2 "create database smaple"
Error I am getting is below "If db2 in not a typo you can run the following command to lookup the package that contains the binary" command-not-found db2 -bash: db2: command not found"
Is this because of environment variable problem ?? or there is only one instance of db2 ie db2inst1 is running in the machine.my user name in appsusr and db2 instance name is db2inst1 are different is this causing problem?? and I am not having super user access.Is this is causing any problem?? do I need super user access is required ??
Just type, echo $PATH in your command prompt , where you can see all the exported paths in your system.
If the db2 path is not found in your environment variable list, then do the following.
export PATH=$PATH:/opt/IBM/db2/V10.1/bin
and then press enter.
I hope this will resolve your issue.
On Linux and UNIX DB2 platforms, the proper way to set your environment variables to run DB2 commands is to source the sqllib/db2profile script belonging to the local DB2 instance owner. That will set not only your PATH but also other important variables that DB2 requires.
In your case, the instance is owned by the db2inst1 user, so your login startup file or batch script should run this command:
. ~db2inst1/sqllib/db2profile
The leading dot is necessary to set the variables in your current shell process, not the sub-process that quickly vanishes after db2profile finishes.
It's more than likely that, if DB2 is installed, it's simply not in your path.
Your path should contain something like:
/opt/IBM/db2/V10.1/bin
which is where the executables live (depending on which version you're running).
Changing your path will probably entail changes to one of the startup files, such as .bashrc or .bash_profile.

Resources