IDL and XPA interaction - idl-programming-language

I'm having a problem getting programs launched by the IDL "spawn" command to be seen by XPA. I'm trying to launch ds9 and then save a region file via IDL. If I open a ds9 window from a terminal window, I can connect just fine with XPA in IDL. However, if I launch ds9 through IDL, I get the error "XPA$ERROR no 'xpaget' access points match template: xpans".
What's the trick I'm missing?

XPA uses a name server program called 'xpans' to map the XPA target name ('ds9' in this case) to the host/socket pair used in the XPA communication. This name server can be started manually at the command line, but an XPA-enabled server such as DS9 will try to start xpans up automatically if one is not already running. In order to do this, DS9 must have xpans in its path. So the simplest explanation for your problem is that xpans is in your shell path which is passed to DS9 in the terminal window, but is not in your IDL path which is passed to DS9 from IDL. You can check this by starting up DS9 in each case, choosing File->XPA-Information, mousing out the XPA_METHOD value and running:
xpaget [xpa-method] -env PATH
This will contact DS9 directly (bypassing the name server) and will tell you the path DS9 has in each case. You also can do a 'ps' before and after DS9 is started in each case, and check for the xpans program ...
A second possible explanation is that IDL does indeed give DS9 the correct path, but is not allowing DS9 to start xpans, i.e. there could be an IDL restriction on whether an exec'ed process (DS9) can exec a sub-process (xpans). If that is the case, you will have to start xpans manually.

Related

SQL Server Management Studio will not redirect output from command line

I am using SQL Server Agent to run a few scripts regularly of type CmdExec with the following format:
"Absolute path to RScript.exe" "Absolute path to script.R" > "Absolute path to log folder\logfilename.txt"
This line will work when used manually in the command prompt but won't create a log file when executed through SSMS. Anyone else have trouble dealing with SSMS or is there a problem with my line?
What also works (in the sense that a file is created) in SSMS is type nul > "Absolute path to log folder\logfilename.txt" so there is no problem with the file path or write permissions.
Not sure if this piping is possible for "normal" commands, but under Step Properties -> Advanced, you can choose to save output to file

Open local index.html with URL parameters using system()

I want to launch a local website from R (in linux) using system(), but I need to pass a parameter, so I need the "URL" to be something like /home/myuser/index.html?q=1.
When I launch it the "?" becomes "%3F":
system('google-chrome /home/myuser/index.html?q=1')
file:///home/myuser/index.html%3Fq=1
But this conversion does not happen when launching a website:
system('google-chrome https://www.google.com/search?q=hello')
https://www.google.com/search?q=hello
So, how can I make system('google-chrome /home/myuser/index.html?q=1') go to: file:///home/myuser/index.html?q=1?
Thanks!

msdeploy.exe with runcommand: problem executing commands

I want to use msdeploy to start a batch file on my remote server.
Usage is like
msdeploy.exe -verb:sync -allowUntrusted:true -source:runCommand="c:/scripts/x.bat" -dest:auto,computerName=https://server:8172/msdeploy.axd?site=xxx,userName=xxx,password=xxx,authType=basic
The x.bat is executed on the remote server. One part of the x.bat is to delete a local file - that works. Then I want to kill a process on that remote server via "taskkill /FI "WindowTitle eq X" /f", but I get the message that no tasks are found.
When I run the x.bat on the remote server, the tasks are killed just fine...
I solved my problem by using schstart to schedule a task which runs one minute later the batch file
according to taskkill documentation:
Remarks:
The WINDOWTITLE and STATUS filters are not supported when a remote system is specified.
according to start documentation:
Title: Specifies the title to display in the Command Prompt window title bar.
So this title is for cmd window itself not job.exe

R script from command line

I wanted to run this example script: http://mazamascience.com/WorkingWithData/?p=912 from Windows command line. So I opened the command line and typed Rscript tryCatch.R 1. However, I keep getting the error message Error: R not found. I did set the PATH environment variable as C:\Programme\R\R-3.0.1\bin. If I just type R.exe, it does start R, but it cannot find the packages that are to be loaded at start (e.g. package 'utils' in options<"defaultPackages"> was not found). I guess I have to set another path to the libraries somewhere, but I haven't got any idea where to do this.
UPDATE: After explicitly typing PATH C:\Programme\R\R-3.0.1\bin (rather than just adding this to the value of the environment variable PATH) it seems that R is found. However, a new problem occurs: In normalizePath<path.expand(path), winslash, mustWork>: path[2] = "C:/Programme/R/R-3.0.1/library": Access denied, the same than for the methods library. Then: Calls: .First ... library -> .getRequiredPackages2 -> library -> normalizePath Execution stopped. I'm using Windows 7 and I do have administrator rights.
Rscript is very handy (R CMD BATCH is the old way to ) specially under windows, But generally under I create a batch file to avoid all path's headache.
For example say launcher.bat:
#echo off
C:
PATH C:\Programme\R\R-3.0.1\bin;%path%
cd PATH_TO_YOUR_RSCRIPT
Rscript tryCatch.R 1
pause
And open a console(using cmd) , go where you have stored your launcher.bat and launch it. Or from the R cosnole using shell:
shell('path_to_launcher\launcher.bat')
I've found out that it was a language-specific problem on Windows 7, similar to what is described here: https://stat.ethz.ch/pipermail/r-help/2011-May/276932.html
After changing PATH to C:\Program Files\R\R-3.0.1\bin the script is properly executed from the command prompt.
Thanks to everyone who tried to help!
I ran into this problem under windows 7, apparently, when setting environment variables>user variables the path is not added into the PATH, so the user must add this path in system variables > PATH
at the end just add the path to your .EXE files and voila.

Installing an MSP using Powershell works on the local machine, fails remotely. Why?

I need some Powershell advice.
I need to install an application's MSP update file on multiple Win08r2 servers. If I run these commands locally, within the target machine's PS window, it does exactly what I want it to:
$command = 'msiexec.exe /p "c:\test\My Application Update 01.msp" REBOOTPROMPT=S /qb!'
invoke-wmimethod -path win32_process -name create -argumentlist $command
The file being executed is located on the target machine
If I remotely connect to the machine, and execute the two commands, it opens two x64 msiexec.exe process, and one msiexec.exe *32 process, and just sits there.
If I restart the server, it doesn't show that the update was installed, so I don't think it's a timing thing.
I've tried creating and remotely executing a PS1 file with the two lines, but that seems to do the same thing.
If anyone has advice on getting my MSP update installed remotely, I'd be all ears.
I think I've included all the information I have, but if something is missing, please ask questions, and I'll fill in any blanks.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
My process for this is:
Read a CSV for server name and Administrator password
Create a credential with the password
Create a new session using the machine name and credential
Create a temporary folder to hold my update MSP file
Call a PS1 file that downloads the update file to the target server
>>> Creates a new System.Net.WebClient object
>>> Uses that web client object to download from the source to the location on the target server
Call another PS1 file that applies the patch that was just downloaded –>> This is where I’m having issues.
>>> Set the variable shown above
>>> Execute the file specified in the variable
Close the session to the target server
Move to the next server in the CSV…
If I open a PS window and manually set the variable, then execute it (as shown above in the two lines of code), it works fine. If I create a PS1 file on the target server, containing the same two lines of code, then right click > ‘Run With PowerShell’ it works as expected / desired. If I remotely execute my code in PowerGUI, it returns a block of text that looks like this, then just sits there. RDP’d into the server, the installer never launches. My understanding of the “Return Value” value is that “0″ means the command was successful.
PSComputerName : xx.xx.xx.xx
RunspaceId : bf6f4a39-2338-4996-b75b-bjf5ef01ecaa
PSShowComputerName : True
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ProcessId : 4808
ReturnValue : 0
I even added a line of code between the variable and the execution that creates a text file on the desktop, just to verify I was getting into my ‘executeFile’ file, and that text file does get created. It seems that it’s just not remotely executing my MSP.
Thank you in advance for your assistance!
Catt11.
Here's the strategy I used to embed an msp into a powershell script. It works perfectly for me.
$file = "z:\software\AcrobatUpdate.msp"
$silentArgs = "/passive"
$additionalInstallArgs = ""
Write-Debug "Running msiexec.exe /update $file $silentArgs"
$msiArgs = "/update `"$file`""
$msiArgs = "$msiArgs $silentArgs $additionalInstallArgs"
Start-Process -FilePath msiexec -ArgumentList $msiArgs -Wait
You probably don't need to use the variables if you don't want to, you could hardcode the values. I have this set up as a function to which I pass those arguments, but if this is more of a one-shot deal, it might be easier to hard-code the values.
Hope that helps!
using Start-Process for MSP package is not a good practice because some update package lockdown powershell libs and so you must use WMI call

Resources