cmd file that starts plink.exe from a nant script not working - nant

I have a .cmd file that start plink.exe and runs several commands.
This works great if I open a command prompt and run the .cmd file.
It does not work when I call the .cmd file from an nant script.
Oh. the nant script is on a windows machine and the plink.exe is connecting to a linux machine.
Any ideas?

Is the NANT script running under the same user, when you manually run it? Make sure the user's have enough access rights.

Do you notice any error messages? Perhaps it is not founding the command executable i.e. plink.exe in the PATH environment variable.
You can put following in your .cmd file:
echo %PATH%
Compare what you get when you run directly on the prompt and run through nant script. Please also provide the plink command line you are using in the .cmd file.

Related

Run a script to load commands into my main script

I have a powershell file that I have downloaded from ScriptCenter that allows me to control and query virtual desktops on my machine (https://gallery.technet.microsoft.com/scriptcenter/Powershell-commands-to-d0e79cc5).
Using their example, I can run that ps1 file at the start of my script to use those commands that the script creates. All fine here.
The only issue with this is that when I run my script, it asks to confirm to run it. This is something I don't want my script to do.
To work around this, I tried using the "PowerShell" command with "-ExecutionPolicy Bypass" set. This removes the prompt to approve the script, however it stops the script from being loaded into my scripts session as I can't use any of the commands it make available by running it.
How do I either run the script first, without it prompting, or execute the powershell command so that it is run in the session space of my script so that its commands are available?
Thanks

Windows cannot find the file specified while running an exe from .bat file

I am trying to run a exe from a .bat file
However, it throws the above error every time I run the .bat file in powershell.
In both the cmd and powershell window it works properly when I navigate to inside the folder and then run the exe file.
My bat file looks like this.
final1.bat
START /w "H:\trunk-2017-10-16" Bootstrapper.exe
Anything I could be missing?
Assuming your executable file is "H:\trunk-2017-10-16\Bootstrapper.exe"
Then you'd need
START /w "" "H:\trunk-2017-10-16\Bootstrapper.exe"
Note that the first quoted argument becomes the window-title.
OR, if you really want "H:\trunk-2017-10-16" to be your window-title, then bootstrapper.exe appears not to be on your path at the present time.

TeamCity running Powershell script, but failing to execute a batch file

I am currently in the process of implementing a deployment method using Teamcity, which runs a Powershell script on my Build Agent, which then configures my Production environment etc.
I have a problem with the Powershell script though, in that it can't seem to run the batch file from it.
The script runs perfectly if I run it manually, it only fails when run via TeamCity.
In the build log I am getting the error:
'myBatchFile.bat' is not recognized as an internal or external command, operable program or batch file.
The batch file and the powershell script are in the same directory and the batch file is called as such:
cmd /c Deploy.bat
I have my TeamCity configuration set up to have the build step for this as:
Script: File
ScriptExecutionMode: Execute script with -File argument
Script Arguments: None
Additional CMD line params: None
I had originally not used the cmd to try to execute the batch file, but executing the batch file like .\Deploy.bat did not seem to work either.
Is there an additional thing I need to set up in order to get the batch file to run? The rest of the script runs fine, just the call to the batch that doesn't.
This is a bit of a wild stab as it's difficult to predict what's happening, but from the description it seems like the path is been altered in the script and it's also dynamic as TeamCity creates temp directories, but if you replace:
cmd /c Deploy.bat
with
cmd /c "$(Split-Path $myinvocation.MyCommand.Path)\Deploy.bat"
then I think this will be able to located the deploy script.
Let me know how it goes.

Cannot Execute FTP commands through ClearCase trigger

I have a ClearCase trigger that runs a .bat file and it works perfectly. What I want to do now is have it run some FTP commands, in my case using WinSCP. I have a command ready in another .bat file which, when run manually, works. When I invoke this .bat file from the .bat launched by the ClearCase trigger, however, it does not work. I have no idea why!
The command in the triggered .bat file is call ftp.bat.
Any ideas? Could it be permissions?
Thanks,
Andrew
As the OP Andrew reports, WinSCP isn't practical when called from another bat.
This would not run:
"C:\Program Files\WinSCP\winscp.com" /script=sftp_script.txt
However, this will, based on psftp (from PuTTY):
echo y | psftp %FTPUSER%#%FTPSERVER% -pw %FTPPASS% -b psftp_script.txt

Run a exe file through a power shell script

I want to run a power shell script which can run a exe file and following are my requirements.
I have that exe file in a remote server location(//ES-WEBSRV01/DBMigration) which is shared to my local machine. Also I want to run that ps file through a cmd.exe.
You can simply call it like any other program:
\\ES-WEBSRV01\DBMigration\something.exe
or, if it contains spaces somewhere along the path:
& "\\ES-WEBSRV01\DBMigration\some thing.exe"
I have no clue what you mean by »Also I want to run that ps file through a cmd.exe.«, though. If you mean that you need a batch file and want to run the PowerShell script from there, then:
powershell -file myscript.ps1