Listen to all Perforce commands made by my client machine to server - version-control

Is it possible to somehow listen to all perforce cammands issued from my machine to the perforce server?
I did some googling yesterday and found a page somewhere about a perforce proxy or broker that would intercept perforce commands and allow you to do what you wanted with them before sending them to the server...and now can't find the page!
I am trying to debug our build process (built using Maven) that is failing while running the maven-release-plugin (prepare).
Cheers.

It was maybe P4Broker (it seems hard to find an official link, hence the google search).

Thanks for the reply - was the link I was looking for though turned out it wasn't what I wanted.
In the end I ended up modifying my Windows PATH so that 'p4' would not directly call perforce but instead execute a bat file:
#echo off
set PERFORCE_HOME="C:\Program Files (x86)\Perforce\p4.exe"
set OUTPUT_FILE=C:\batScripts\output\p4out.txt"
echo =========================== >> %OUTPUT_FILE%
echo ===== PERFORCE DEBUG ====== >> %OUTPUT_FILE%
echo =========================== >> %OUTPUT_FILE%
echo $ p4 %* >> %OUTPUT_FILE%
echo =========================== >> %OUTPUT_FILE%
echo Timestamp: %Date% %Time% >> %OUTPUT_FILE%
echo Vars: >> %OUTPUT_FILE%
%PERFORCE_HOME% set >> %OUTPUT_FILE%
echo ` >> %OUTPUT_FILE%
%PERFORCE_HOME% %*

Related

Validate if command was successfull in a batch file or revert back all settings

Please check my batch file command as I need to dis-join computer from old domain and join it to a new one.
Sometimes computer succeeded to dis-join the computer but fails to add it in a new domain so this computer will be out of domain. I need to add command to validate if the computer is successfully joined to the new domain otherwise revert it back to the old domain.
#echo off
netdom.exe remove %computername% /domain:MyOlddomain.local /UserD:Myusername /PasswordD:Mypassword
Ping 127.0.0.1 -n 5 >nul
netdom.exe join %computername% /domain:MyNewDomain /UserD:Myusername /PasswordD:Mypassword
Ping 127.0.0.1 -n 5 >nul
shutdown -t 5 -r -f
The best way about it is to use a IF statement.
The basic structure of a IF statement is as follows.
IF EXIST "%1" (
echo "it's here!"
) ELSE (
echo "it isn't here!"
)
Going about it like this will allow you to revert when needed.
More in depth reading!

Need to extend batch functionality to checkout multiple files from SVN

I have a batch script that checks out any project from the SVN when typed. I have to extend the functionality so that multiple files that user decides can be checked out and a simple approach to it. Right now, my script lists the files from SVN, gives user the choice of entering any name and checks out the trunk of every project using a very basic navigation method. The code is provided below :
echo ============================================================
echo This batch file will automate checking out a project from eclipse
echo ============================================================ %NL%
set svnroot= svn://some_dir
set svnroot_temp= %svnroot%
svn ls !svnroot_temp!
:top
set /p direct=Enter directory..press 1 at anytime to return to root directory and type checkout at anytime to checkout the project :
if /i !direct!==checkout ( cls
set loc=!svnroot_temp!
set proj=!dir!
if /i !direct!==1 (cls
set svnroot_temp=%svnroot%
svn ls !svnroot_temp!
goto :top
)
set svnroot_temp= !svnroot_temp!/!direct!
svn ls !svnroot_temp!
set dir=!direct!
goto :top
)
if exist "%javawork%/%proj%/" ( echo %NL%project already exists...
PING 1.1.1.1 -n 1 -w 3000 >NUL
echo %NL%updating the folder%NL%
svn update %javawork%/%proj%/*
goto :correct
)
set CheckOutLocation= user_preferred_location
svn checkout %loc%/trunk %CheckOutLocation%/%proj%/trunk/
echo %NL%%NL% Copying was successful! %NL%
PING 1.1.1.1 -n 1 -w 2000 >NUL
I wanted help in knowing if there is an easier way so that more projects can be checked out from SVN. Like setting numbers to the svn ls list and then choosing numbers for the projects to checkout. Or any way of making checking out many projects more convenient. Any help will be appreciated . Thanks!
Add numbers to svn ls by piping it to findstr /n and then input a space-delimited sequence of project numbers to checkout:
svn ls !svnroot_temp! | findstr /n .
set /p checkout=Enter space-delimited numbers of projects to checkout
set projNo=0
for /f "tokens=*" %%a in ('svn ls !svnroot_temp!') do (
set /a projNo+=1
for %%b in (!checkout!) do if %%b==!projNo! (
svn checkout %%a/trunk %CheckOutLocation%/%%a/trunk/
)
)

Pre-Commit Windows Hook to Require Issue Number in Comment

I am looking for a way to reject commits that lack a bug issue number in their comments. The system I am setting up uses VisualSVN Server on Windows Server 2012 and MantisBT on a LAMP server for bug tracking. This question has been asked before, but the repository in that case was on a LAMP server. I am looking for a batch or PowerShell script which does not depend on PHP or compiling code. Ideally, the hook would require "issue #1234" or "issues #12 and #34" to be present somewhere in the commit message.
Based on this batch file:
After this block:
setlocal enabledelayedexpansion
set REPOS=%1
set TXN=%2
set SVNLOOK="%VISUALSVN_SERVER%\bin\svnlook.exe"
REM Concatenate all the lines in the commit message
FOR /F "usebackq delims==" %%g IN (`%SVNLOOK% log -t %TXN% %REPOS%`) DO SET M=!M!%%g
add the check:
echo !M! | findstr /i /r /c:"issues* *#[0-9][0-9]*" >nul
if errorlevel 1 (
echo "Sorry, commit message should reference an issue" >&2
exit /b 1
)

Passing parameter from Client CMD through ICA file to launch published Citrix App

I'm trying to send a simple string parameter from C# web app code using CMD line call to ICA file to Citrix XenApp Server to launch a specific published application (Macro Scheduler macro compiled into exe), NOT the whole citrix desktop.
I have a web app with cmd line code using
"C:\Program Files (x86)\Citrix\ICA Client\Wfica32.exe" C:\someICAfile.ica \Param:"/username=SomebodysName" .
I've also tried for the parameter syntax: /username=SomebodysName, /Param:"/username=SomebodysName"
and about a million other combinations of quotes and slashes.
I used Citrix QuickLaunch to write my ICA file, in which the only thing I changed was InitialProgram=#ApplicationName \Param (I added the \Param). I've also tried /username and \Param=SomebodysName and I can't get any of those to work either. I've even tried just hardcoding the name in there and I can't get it to go through.
The exe is expecting a parameter "username" and when called locally from the cmd prompt it works using UsernameProgram.exe /username=somebodysname. I made sure to include the "%*" at the end of the commandlineexecutable in the Citrix Xenapp application location properties to ensure that it can accept a command line parameter.
This is all using C# and XenApp 6. Everything works except passing the parameter through, and I have no idea where the parameter is lost, if it even gets anywhere.
I feel like I have tried every combination of /'s \'s and "'s so if anybody could please help me out with the syntax, I'd really appreciate it! I did try looking into the ICA Client SDK in the c# code, but it seems to just manually do what an external ICA file will do. If this is wrong, however, please let me know. I'm approaching the point where I'm just going to try it regardless because I'm completely out of ideas. Please help.
Thanks!
I ended up calling a .bat file from my C# code by using the following:
Process proc_Launch = new Process();
proc_Launch.StartInfo.FileName = "CreateTempICA.bat";
proc_Launch.StartInfo.RedirectStandardError = false;
proc_Launch.StartInfo.RedirectStandardOutput = false;
proc_Launch.StartInfo.WorkingDirectory = #"C:\WorkingDirectory";
proc_Launch.StartInfo.Arguments = #"""/username=somebodysname""";
proc_Launch.Start();
reference: Run bat file in c# with .exe and .def code
In the .bat file, I create an ICA file passing in the username paramter as follows:
#echo off
:makefile
pushd %temp%
set icafile=temp.ica
#echo [WFClient] > %icafile%
#echo Version = 2 >> %icafile%
#echo HttpBrowserAddress=ServerName:8080 >> %icafile%
#echo ProxyType=Auto >> %icafile%
#echo ConnectionBar=0 >> %icafile%
#echo [ApplicationServers] >> %icafile%
#echo ApplicationName= >> %icafile%
#echo [ApplicationName] >> %icafile%
#echo Address = ApplicationName >> %icafile%
#echo InitialProgram=#"ApplicationName"%1 >> %icafile%
#echo ClientAudio=On >> %icafile%
#echo AudioBandwidthLimit=1 >> %icafile%
#echo CGPAddress=*:#### (use actual numbers here though) >> %icafile%
#echo CDMAllowed=On >> %icafile%
#echo CPMAllowed=On >> %icafile%
#echo DesiredColor=8 >> %icafile%
#echo ConnectionBar=0 >> %icafile%
#echo TWIMode=On >> %icafile%
#echo Compress=On >> %icafile%
#echo TransportDriver=TCP/IP >> %icafile%
#echo WinStationDriver=ICA 3.0 >> %icafile%
#echo BrowserProtocol=HTTPonTCP >> %icafile%
#echo [Compress] >> %icafile%
#echo DriverName= PDCOMP.DLL >> %icafile%
#echo DriverNameWin16= PDCOMPW.DLL >> %icafile%
#echo DriverNameWin32= PDCOMPN.DLL >> %icafile%
start %icafile%
popd
The %1 in the InitialProgram component is where the argument is used from the C# code.
reference: http://www.virtualizationadmin.com/files/whitepapers/MetaframeXP/Connecting_to_a_Citrix_server_from_the_command_line.htm
The last step is to make sure in your Citrix Delivery Console to make sure that the Location properties of the published application for the CommandLineExecutable has a "%**" after it, including the double quotes. I believe adding the 2nd asterisk lets the parameter get through the command line validation and allows it to be used when the application is opened. Either way though, it worked with two of them and not with one of them.

PowerShell raw FTP

I am looking to use FTP to write a mainframe jobstream. To do that, I can connect to the mainframe via FTP and run these commands:
QUOTE TYPE E
QUOTE SITE FILETYPE=JES
PUT myjob.jcl
So, how would I do this in PowerShell? I have read plenty on standard FTP transfers, but I haven't seen anything about customizing the calls for prep.
Thanks for reading.
EDIT
Here is the solution I came up with, per the answer here and this article:
#echo off
echo user %1> ftpcmd.dat
echo %2>> ftpcmd.dat
echo QUOTE TYPE E>> ftpcmd.dat
echo QUOTE SITE FILETYPE=JES>> ftpcmd.dat
echo put %3>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat %4
del ftpcmd.dat
Usage:
C:\>fileup user123 pa$$word myfile.txt ftp.server.com
Could you use the -s switch for FTP and specify a file that contains your commands to run?
-s:filename Specifies a text file containing FTP commands; the
commands will automatically run after FTP starts.
Then you can call this in PowerShell as
ftp -s:<myscript> <host>
If you're comfortable with .NET and want to do it programatically, there is a similar question/answer here:
Upload files with FTP using PowerShell
It pretty much goes comes down to using a System.Net.FtpWebRequest for the job. At first glance it seems fairly straight forward.