Rscript and Incredibuild - rscript

I have a simple function f1(paramter) in a "functions.txt" file.
I write a batch file test.bat as follows
FOR /L %%G in (-100,1,100) do xgSubmit.exe /group=tt1Test /command Rscript.exe -e
"source('functions.txt');f1(%%G)" > "Out.%%G.txt"
In the windows command prompt I use
xgConsole.exe test.bat /openmonitor /AvoidLocal=ON
What I am trying to do is compute function f1() in different machines using incredibuild.
What I observe is the function that are running locally returns a value in files
Out.%%G.txt but the functions running remotely fails with the following error
Error in structure(.Internal(Sys.getenv(as.character(x), as.character(unset))), :
unsupported conversion to 'UCS-2LE' from codepage 1252
Calls: local ... eval -> eval -> as.vector -> Sys.getenv -> structure
Execution halted.
The remote machines do not have R program installed.
Am I doing the correct thing ?
Should incredibuild and Rscipt be able to work even though R program is not installed in the remote computer ?
It would be very kind to provide a detailed answer.

It seems like a Unicode problem in the remote machines.
Many Unicode problems have been fixed since this question was submitted.
I assume your bug is already fixed in the latest version of IncrediBuild.

Related

How can I run ROS commands through a C based system() call?

I have this c based program to do some benchmarking and whatnot which I use heavily. I am a ROS noob, just starting to delve into ROS code to do some analysis.
Currently, I need to be able to call ros based commands (i.e. rosbag play, roscore, etc) through the system() function.
For those who do not know how it works, it basically just executes the command (i.e. system("ls"); system("./testScript.sh").
Right now I have a bash script set up to essentially run several small things including ROS commands. Executing the script works perfectly, but executing it through system always give me an error regarding ROS_cmd: Not found.
For example:
#/bin/bash
ls
echo hi
rosbag play rotating_detergent_1_6.bag
Gives me output error of : rosbag: not found - all the while executing the ls and echo
This happens independent of the ROS based command.
Any one know what is wrong?
edit: So to add, the C program is called in sudo. I noticed that the problem seems to be that system() executing in sudo does not have the appropriate ROS PATH.
For example:
echo $PATH -> /opt/ros/melodic/bin : rest
sudo su; echo $PATH -> rest
How should I go about properly addressing this?
ROS environment is a bunch of variables:
ROS_DISTRO
ROS_ETC_DIR
ROS_PACKAGE_PATH
ROS_PYTHON_VERSION
ROS_VERSION
ROS_ROOT
ROS_MASTER_URI
ROSLISP_PACKAGE_DIRECTORIES
Unless you want to set them all by yourself, you can use a very convenient uitlity script provided by ROS. The script is usually at /opt/ros/<ros_distro>/setup.bash
Just source the script in the terminal where you run your C program and then run your program.
source /opt/ros/<ros_distro>/setup.bash
You should not need sudo but in case you do , use it with -E flag to preserve the environment.

32/64 bits Issue with psr.exe

I currently have an issue with psr.exe. Actually, it works perfectly with the following command :
C:\windows\system32\psr.exe
C:\windows\syswow64\psr.exe
psr.exe (with system32\cmd.exe and syswow64\cmd.exe).
BUT, it does not work when my program (a 32 bits program running on a 64 bits windows 7) use this bat to start the application. Nothing happens.
My programm can open a notepad from a bat files, or execute whatever you want, but it does not work with psr.exe.
Can you give me some tips? Maybe it is not a 32/64 bits compatibility issue but I have other no idea about why this does not works...
EDIT :
The batch file content is:
C:\windows\system32\psr.exe
The program running this bat is written in C, it uses this function to start it:
CreateProcessAsUser(
hTokenDup,
NULL,
"C:\\toto\\mybat.bat",
NULL,
NULL,
FALSE,
NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE,
lpEnvironment,
NULL,
&sInfo,
&ProcessInfo)
It works perfectly if the .bat file contains C:\windows\system32\notepad.exe instead of C:\windows\system32\psr.exe.
If I double click on my bat files containing C:\windows\system32\psr.exe from my desktop, it works perfectly, but from my C program, it does not work.
(NB : My c program works with other .exe files like notepad for example)
Many thanks.
Johan
If a 32-bit program running on 64-bit windows OS tries to access a file C:\windows\system32\psr.exe, Windows redirects the request to file C:\windows\syswow64\psr.exe.
To start a 64-bit system application from 32-bit environment you need to execute C:\windows\sysnative\psr.exe which will be redirected to "real" C:\windows\system32\psr.exe.
To run the bat-file entirely in a 64-bit environment, execute C:\windows\sysnative\cmd.exe with following parameters: /c "C:\toto\mybat.bat"
However, this does not appear to be a problem in your case.
Could it be that the user you are trying to impersonate has a corrupted profile, home folder, environment, or does not have some sort of privilege required by psr.exe application?
Or maybe the app requires user profile to be loaded but you didn't load it by calling LoadUserProfile() beforehand?
Try testing by running your batch file like this:
c:\windows\syswow64\runas.exe /noprofile /env /user:INSERT_USERNAME_HERE "C:\toto\mybat.bat"
Does it work? Now try removing /env and/or replacing /noprofile with /profile. Does it now?

Unable to start .bat script under Windows 7

This is strange: in general, .bat scripts work fine on this machine. So the PATH variable is fine.
However, I have one script that creates the error message
--> 'C:\Windows\system32\cmd.exe\' is not recognized as an internal ....
Here is the one-line script:
--> #echo %1 | "C:\Program Files\putty\PSFTP.exe" -pw xxx User#Host
This script is working fine on two other Windows 7 machines, just not on mine.
Any ideas what to check?
Is it possible you are using a 64bit version of Windows?. The path may need to be set to point to "C:\Program Files (x86)\Putty"
Actually, the problem had nothing to do with the specific command. Even a
dir | dir
from the command line threw the same error.
I did find the solution here:
https://superuser.com/questions/557387/pipe-not-working-in-cmd-exe-on-windows-7
Problem was the environment variable ComSpec; somehow it had a bad character in the field. I removed that darn back-slash and all is fine.
Thanks for looking at my problem.

StartService error 2

I've written a very simple batch file that bluescreens windows 7 (ultimate,enterprise,home) beyond normal repair, by making an attempt of loading a Win32 exe-file (the well known notepad.exe) into the operating system's kernel. Feel free to test it in a Virtual Machine, just open it as an administrator. Do NOT run this as administrator on your primary computer.
#echo off
sc create bluescreener binpath = C:/Windows/System32/notepad.exe type= filesys start= boot
sc start bluescreener
timeout /t 30
However: When I run this program on windows 10, it successfully creates the service, but it doesn't start. Instead it returns the following error:
[SC] StartService Failed 2: The system cannot find the file specified.
It is referring to the binpath I set in the batch file. I am sure this path exists, and that this is the exact path name. I don't understand why it can't find the file. I have tried using backslashes instead of forward-slashes, and that didn't work either. (I have forward-slashes because I have a python program that writes this batch file, and the line break in python uses a backslash, and that conflicts with the path.)
I tried the "sc qc bluescreener" test that shows information about the service I have created. This is what comes up. (It is the same thing that comes up when I test it on windows 7, where it works.)
[SC] QueryServiceConfig SUCCESS
SERVICE_NAME: bluescreener
TYPE : 2 FILE_SYSTEM_DRIVER
START_TYPE : 0 BOOT_START
ERROR_CONTROL : 1 NORMAL
BINARY_PATH_NAME : \SystemRoot\System32\notepad.exe
LOAD_ORDER_GROUP :
TAG : 0
DISPLAY_NAME : bluescreener
DEPENDENCIES :
SERVICE_START_NAME :
I can't find any explanation for why it can't find the file.
When I try to reboot windows 10 after creating the service, it can't boot, which means that the service is probably working and that the file was located. I just want to know why Windows 7 can find the file and immediately bluescreens, while Windows 10 can't find the file and needs to be rebooted for the service to run.
Any suggestions on how I might reproduce the same effect i get on Windows 7, but on Windows 10?

Why multiple arguments with spaces are not interpreted correctly in a batch script?

I'm running an exe with multiple arguments that may or may not contain spaces. I encloses them with quotes but they are somehow not passed to the exe correctly.
Here's the command i'm using:
makeblastdb -in "D:\d b\sequence.fasta" -input_type fasta -dbtype prot -title xd -out "D:\d b\xd"
which I think cmd should pass 10 arguments to the exe but somehow it isn't passing correctly.
this is the result i get
BLAST options error: File "D:\d" does not exist.
which is basically saying that the second argument is being chopped for some reason?
Any help will be appreciated, thanks!
Based on your comments to your question, the BLAST utility does not properly handle quoted paths with spaces, and your volume does not support short file names.
Obviously you can move your working directory to a path that does not contain spaces.
An alternative is to use SUBST to temporarily create a virtual drive that points to your problematic path.
subst K: "d:\d b"
makeblastdb -in "K:\sequence.fasta" -input_type fasta -dbtype prot -title xd -out "K:\xd"
subst /d K:
Type subst /? for help with the command.
Update based on fact that you are running the command from within python
In your comment to this answer, you state you will attempt to get the command to work from within python. That could be the entire source of your problem.
You should try to run the command in your question directly from a Windows command prompt (cmd.exe console).
If the command does not work from the command prompt, then the problem is indeed with the BLAST utility, and SUBST is a good solution.
If the command does work from the command prompt, then the problem is with how you are shelling out the command from python, and the SUBST command should not be required.
I'm not a python user, but I see that many people have similar problems when using python on Windows. Perhaps this will help: How do I execute a program from python? os.system fails due to spaces in path
makeblastdb has an odd escaping convention. Try this:
-in \""D:\d b\sequence.fasta"\"
Unfortunately this doesn't work for -out, so dbenham's answer is probably best.
Alternative is you can try using directory shortname for "D:\d b" which you can find by running dir /X command on your D drive. For instance if I run dir /X on my C drive here is what I get:
01/21/2013 09:47 AM <DIR> PROGRA~1 Program Files
So you want to use C:\Program Files you can alternatively use C:\PROGRA~1.

Resources