psexec command to run bat file present in some directory on remote server - remote-access

I want to achieve following in one single command.
PS D:\custom> .\PsExec.exe \remoteserver -u user -p password -accepteula -s cmd
PsExec v2.34 - Execute processes remotely
Copyright (C) 2001-2021 Mark Russinovich
Sysinternals - www.sysinternals.com
Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.
C:\Windows\system32>D:
D:\ cd test
D:\test>testjob.bat
D:\test>hostname
windowsrundeck
I don't want to copy my bat file from my local machine to remote machine. instead I want to directly execute a bat file present in D:\test folder of remote machine.
Also, Is it possible to run multiple commands in one psexec command ?
Also, If I use this psexec command in automation tool, it just gives me exit code, note verbose of what it has done.. How can I see what my bat file is doing when I run my psexec command from automation tool?

I managed to fix it by adding all commands in one bat file. and I was able to execute the batfile in D:\test by using -w parameter in psexec command. -w sets the working directory on remote machine.

Related

Unable to activate virtual environments on Windows 10 with Python 3.7 using cmd

I am having a problem with activating a virtual environment by the name FYP using cmd on Windows 10. I checked the bat file, which is of 1KB size.
See the below commands or image. It should have (FYP) on the start after running the activate.bat file.
C:\Users\Manish>M:
M:\>ENV\FYP\Scripts\activate.bat
M:\>
But using a similar command in PowerShell or VS code will get the environment activated.
Check the below image or command. It is showing (FYP) on the start of the command, and FYP env is now activated.
PS M:\> cd .\ENV\
PS M:\ENV> .\FYP\Scripts\activate
(FYP) PS M:\ENV> cd ..
(FYP) PS M:\> cd .\projects\
Earlier when I had Windows 7, the virtual environment was getting activated on both PowerShell and cmd as well. And I used similar commands in both cmd and PowerShell.
M:\ENV>FYP\Scripts\activate
But with Windows 10, I don't know why it is not getting activated on cmd.
Please help?
Is there any specific reason why the virtual environment is not activating.
The command line needs to know where to start. Add .\ to tell it that start in the current directory.
c:\Program Files (x86)>".\Internet Explorer\iexplore.exe"
So basically, I can easily activate it through Visual Studio Code's terminal(Powershell), using the command
<PATH_TO_VENV>\Scripts\activate
<PATH_TO_VENV>: where you have created the virtual environment.

Run and start denodo platform using Command Line Linux Remote Server without GUI

Run Denodo Platform sh files using Command Line Linux Remote Server.
Denodo Platform showing GUI to start Virtual DataPort, and I can only interact using Command Line only.
Is there a way to do this?
ssh into the server and go to your DENODO_HOME\bin folder
run this command there:
sh vqlserver_startup.sh

Ssh command to Windows machine via bash script executed from Jenkins slave

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.

Permissions Error in Perl Script for Linux

I'm trying to install the Touchmouse server for Linux. The software is a perl script that I have tried to run via terminal, using the perl command. The software I'm trying to run is here: https://github.com/mycroes/touchmoused
This is the output from terminal:
:~/Desktop/touchmoused-master$ perl touchmoused
Can't open /dev/uinput: Permission denied at touchmoused line 242.
:~/Desktop/touchmoused-master$ Established under name '<name of computer>'
I am new to Linux but have some experience with Terminal.
Thanks!
From the creator of the script:
Just download it, chmod +x and run it (as root, it needs access to /dev/uinput and it wants to register with avahi).
Regards,
http://blog.mycroes.nl/2011/04/touchmoused-logitech-touch-mouse-server.html
Your user won't have permissions for /dev/uinput, also check that /dev/uinput is the correct location for your distribution, the script allows you to override this with the -device flag.
So either make it executable so you don't have to enter 'perl' and then run with sudo or have root run it on startup.

How to transfer file from Windows to Linux server, process it with shell script, and download results back

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)

Resources