Jenkins on unix executing script on windows server - sql

I have a CI environment set up that build my project. It creates a set of sql server files, that i want to to send to my windows server. For that im looking into using scp, by installing copssh.
scp -r /file_in_unix/ user#windows_hostname:/cygdrive/c/
I want to execute a batch file on the windows server, but dont know how to do this?
any ideas?

Quite fast workaround is just to connect your Windows machine to Jenkins as another node. Your current unix job can trigger this job after successful execution.

Related

TFS SSH task in Windows Machine failed

I tried to connect a Windows machine that exist in another domain than our TFS 2018.3 exist.
I added "SSH" task, and I created new SSH endpoint with the remote machine IP, username and password, without a private key. I configured in the remote machine access of SSH for this username & password.
In the SSH task, I configure a simple shell command: ls.
The TFS agent succeeded to connect the machine but failed with this error:
Unable to execute command or shell on remote system: Failed to Execute process.
Full log:
2019-08-15T13:22:54.1491966Z Trying to setup SSH connection to ********#myserverinanotherdomain:22
2019-08-15T13:22:54.4085564Z Successfully connected.
2019-08-15T13:22:54.8120684Z tr -d '\015' <"./sshscript_1565875374136" > "./sshscript_1565875374136._unix"
2019-08-15T13:22:54.8121422Z Unable to execute command or shell on remote system: Failed to Execute process.
2019-08-15T13:22:54.8121745Z
2019-08-15T13:22:54.8180230Z ##[error]Command tr -d '\015' <"./sshscript_1565875374136" > "./sshscript_1565875374136._unix" exited with code 4294967295.
I think because it's a Windows machine and I try to execute a shell script. If I will install Git bash, for example, it can help?
Does the SSh task support only Linux machines? if yes, how can I connect a machine that exists in another domain?
SSH being a communication protocol is agnostic of OS. It is not Linux specific. But there seems to be a limitation for using SSH task on windows machine/build agent. Take a look at this similar question here: Not able to run bash script from windows using vsts.
I haven't found a documentation that clearly declare the SSh task not support on Windows machine. But I have found a task which also uses SSH--Copy Files Over SSH task. And according to the Q&A in official link:
Is this task supported for target machines running operating systems
other than Linux?
This task is intended for target machines running Linux.
For copying files to a macOS machine, this task may be used, but authenticating with a password is not supported.
For copying files to a Windows machine, consider using Windows Machine File Copy.
Instead of SSH. You should be able to use a local account on the build server and when entering the credentials. The account must have the same password as the account in the other domain. In other works make sure build account which run on the build agent are able to connect another domain.
Also make sure there is a trust relationship between the domains.

Open app as gui via powershell for a specific user

I have an app that needs to run as a GUI, I'm trying to automate it's launch at startup without the need to remote desktop to the windows server 2008 R2 and manually start it. I currently use a powershell script at startup to perform multiple tasks but have not found a way to launch this gui app in the foreground for the user. So for now I still need to remote in and manually kill / start it.
psexec.exe will help you here.
this guy can execute interactively in a remote execution. PowerShell in remoting cannot be used for interactive tasks.

Which SQL server is running on a Linux Box?

I have a redhat linux server that I am trying to work out what is running on it. I have inherited it and am trying to move it to a different server.
I know there are several SQL databases running on it but I don't know what SQL package is controlling them.
Is there a way to find out?
You can use the Red Hat services command to get a list of daemons running. One of them should be the database server.
sudo service --status-all
And if that doesn't work (e.g. it's not being run as a service) you can always do
ps -ef|grep 'postgres|mysql|oracle|sql'

Run an executable when a web address is called

I'm trying to find a way to run a dos executable when called by another server.
It's hard to explain sorry,
So I have a windows server 2008r2. On it is a dos exe that I need to run.
I also have a linux ubuntu server that hosts some SQL and web pages (apache).
Users update a table in the linux box, and when they do I need to run a dos exe on the windows box.
I don't want to use scheduled tasks on the windows box, because updates need to happen at the moment the data is changed in the linux box with little delay.
Any way anyone can think of that the linux box can 'call' the windows server to run the exe?
Thanks :)

remotely run a script sitting in a windows server from a unix box or from another desktop (Say windowS)

I have to run a batch job which sits in the windows server from my unix box.
Or from my local machine.
The win server has a userName/Pwd .
How do i programmatically connect to the windows machine and run the batch?
(The batch will change some file permissions in that machine)
Please let me know if there is a better way of handling this situation
A lot of this depends on how you authenticate on the windows machine, the network relation you have to it from your local and unix machine and what level of permission you will need to run the task ons the remote batch file.
I can say that in Windows, you could start by possibly creating a script that stores the username and password needed to connect to the remote machine in a variable, and in that script have it connect to the machine over a network and run the batch as that user.
How woudl you connect to the remote windows server? is it on a LAN or VPN type environment, do you connect with ssh or do you normally map it over the network?>