I have two servers Server A which has a shell script - 'Process_Backup.sh'.
I executed this script on server A - './Process_Backup.sh' and it executed fine. Basically this script connects to my oracle database on Server A and executes a procedure.
What I need to do is execute the script 'Process_Backup.sh' on server A from a different Server B.
I tried following command from Server B
ssh test#server1.xxx.com "cd Scripts/Shell; ./Process_Backup.sh"
But I am getting following error-
line 49: sqlplus: command not found
I have all the software installed on server A so not sure why am I getting this error. I am new to linux environment. I have gone through most of the question posted here but mine seems to be a different case.
Any help is appreciated
Oracle installs a file oraenv that sets some environment variables including the PATH where commands like sqlplus are. That file is included when you start your login shell, the commands to do that were probably created by the installer.
Use
ssh test#server1.xxx.com "source /path/to/oraenv; cd Scripts/Shell; ./Process_Backup.sh"
The file oraenv is probably somewhere below /usr/local.
Related
I have a little node application on a server (node mailer) that I run by going to its source folder and executing npm start. I figured the best way to run this automatically would be to create a my_script.sh file and drop it in the init.d directory of my debian box. Inside the file (below the !#/bin/bash line), the code to execute is
'/opt/mycode/source/npm start'
I save the line to the .sh file and restarted the machine, but so far haven't got it to work. My question is: is this even how you start a script like this (using that command and an .sh file)? It does start normally when I do it manually (when I navigate to it and run npm start in the terminal). I included the single quotes around it because of the space between npm start. Also, if I want to verify that it worked, which process would I look for other than just pinging my smtp mailer? Finally, I know I need to run:
update-rc.d my_script.sh defaults
but I was also confused at to whether I had done this correctly either (is it just the name of the file that goes there or the file plus the extension)?
The script that you leave on the init.d folder should not have any extension and should have functions to start, stop and get the status of the service (your application).
I'll leave a link with an example as well as with some basis in order to build the Linux service script.
I would suggest reloading the daemon with systemctl daemon-reload in order to refresh the Linux service files once you add a new one.
I am facing an issue in jmeter that I want to know if I can solve.
I need to run a script in distance computer.
when I run the script via command line in my computer it is working.
plink -ssh jenkins#178.27.288.288 -pw passtest sudo /opt/test/test.sh
I want to run it in Jmeter from my computer (the same as the script run).
I tried the ssh sampler that did not work
I want to useage the OS sampler, Is it can be done? Can I run script on distance computer?
The only explanation I found was from blazemeter site, and mentioned:
"Again, since running the “plink” program via the OS Process Sampler is quite easy,"
remote machine: jenkins#178.27.288.288,
password for remote machine: passtest,
command: sudo /opt/test/test.sh
So can someone please advise
I added the OS sampler
and get this message:
Exception occurred whilst executing system call: java.io.IOException: Cannot run program "sudo /opt/test/test.sh" (in directory "plink -ssh jenkins#178.27.288.288 -pw passtest "): CreateProcess error=267, The directory name is invalid
Can someone please advise how to run the command in the remote computer?
once again if I take the full line into command command line it is working, but after I cut it for Jmeter it is not working? what am I missing
Command arguments need to go in the "Command parameters" section, not in the "Working Directory"
I would suggest running your script via cmd.exe interpreter, so the actual command would be cmd, not the Linux command
It is more safe to provide -hostkey parameter as if the remote Linux machine is not in known_hosts your script will get stuck
Assuming all above your OS Process Sampler configuration should look like:
It might be easier to use JSR223 Sampler where you can invoke a program and get the output as easy as:
"c:\somefolder\plink.exe -pw passtest sudo /opt/test/test.sh".execute().text
More information on the approach: Apache Groovy - Why and How You Should Use It
I'm have some bash script (myscript.sh), one of logical steps is to run ssh command against Windows machine running open-ssh.
When I'm running the script (myscript.sh) from the shell everything works fine.
But when I am running same script from Jenkins (CentOS 7.3) it fails to retrieve content via ssh command: ssh root#windows-server hostname.
Please need your help.
The user running the jenkins process do probably not have the correct executable rights or group membership to do so.
Try
sudo -u "jenkinsuser" myscript.sh
If that fails you confirmed the issue.
Change the execute rights on your script or put the server process owner in the right group if this is the case.
I am having some difficulty running jobs over SSH. I have a series of networked machines which all have access to the same Home folder (when my executable is installed). While working on one machine I would like to be able run my code through ssh using the following sort of command:
ssh -q ExecutableDir/MyExecutable InputDir/MyInput
If I ssh in to any of the machines I wish to run the job on remotely and simply run:
ExecutableDir/MyExecutable InputDir/MyInput
It runs without fail, however when I run through SSH I get an error saying some shared libraries can't be found. Has anyone come across this sort of thing before?
ok I figured it out myself.
It seems when you run things through ssh in the way shown above you don't inherit the path variables etc. that you would if you ssh-ed in 'properly'. You can see this by running:
ssh RemoteMachine printenv
and comparing the output to what you would normally get if you were connected to the remote machine. The solution I then went for was to run something like the following:
ssh -q ExecutableDir/MyExecutable source ~/.bash_profile && InputDir/MyInput
Which then gets all the paths and stuff you might need from the bash_profile file on the remote machine
I normally do this using WinSCP: I transfer a .tex file from my local Windows machine to a Linux server. I run a script (on the server) to pdflatex the file for me. And I use WinSCP again to copy the output .pdf to my local Windows machine again. I would like to automate the copying process in my script.
So the first step is to copy file.tex from C:\Doc...\source to ~/Documents. I think I need to use the scp command, but the server sees my local machine as a remote machine. That's why I'm confused as to how the first directory needs to be specified:
$scp C:\Doc...\source\file.tex ~/Documents
doesn't work because the server doesn't know how to talk to my local machine. I have the same issue for the scp command I need to use to copy file.pdf back to my local Windows machine.
Can anybody help me with these two scp commands?
Thanks in advance!
You can use WinSCP in scripting mode. It (naturally) supports the upload/download. But it can also execute the shell script on the server with call command (with some limitations, which should not matter in your simple case):
winscp.com /log=winscp.log /command ^
"open scp://username:password#example.com/" ^
"cd /remote/path" ^
"put my.tex" ^
"call pdflatex ..." ^
"get my.pdf" ^
"exit"
(I'm the author of WinSCP)