Run command through External Tools Configuration in Eclipse on Mac - eclipse

I'm try to execute the following string of commands through a an External Tools Configuration in Eclipse (it basically deploys a build to a server and touches the server's plan file, causing the server to update itself with the new build):
mvn -P virgo package -o -Dmaven.test.skip=true && touch ${env_var:SERVER_HOME}/pickup/{project_name}.plan
On Windows, I was able to pass this string (with slight modifications) to cmd.exe using its /c argument and see the output in Eclipse's Console.
How can I get this behavior on Mac?
UPDATE
Another way of phrasing the question is, how can one feed an argument to Terminal to be execute (i.e., Terminal.app -argument "mvn -P virgo package -o -Dmaven.test.skip=true && touch ${env_var:SERVER_HOME}/pickup/{project_name}.plan")?
Another possibility would be to use a shell script, but I don't have experience with them.

Related

Eclipse Makefile project to be built within a Cygwin environment

We have a project (C) (not a Cygwin exe project, but some embedded cross-compiled one), which has a Makefile designed to be used from within a Cygwin environment. That is the intended use is to open a Cygwin terminal, go t the project directory and run make from there.
I can import this project in Eclipse as a Makefile project, but apparently the regular build command from within Eclipse won't work as it is trying to invoke make in the native (Windows) environment. Is there a way to make Eclipse to run the Cygwin, invoke a make command in it and have the regular CDT error parsers to work? Perhaps by creating a custom builder?
I have managed to work around this problem by using a build script invoking some cygwin commands:
build.bat:
#echo off
c:\cygwin64\bin\bash --login -c "cd %cd:\=/%; make %*"
Breakdown:
c:\cygwin64\bin\bash --login -c "<command>" - used to invoke a command from within cygwin environment
cd %cd:\=/%; - is a "dos" %cd% variable (current path) with backslashes replaced by slashes - to avoid these to be stripped down as unescaped.
make %* - invoke the cygwin make command with all of the arguments passed to this batch file - this is to let Eclipse pass the build target and/or build flags.
Now in "project build" tab in eclipse I replace the make command with build.bat and it is working like a charm. The only drawback i to have this file in addition to the other project files, but since it is pretty generic it can be reused in any project with these restrictions.

How to open cygwin & execute bash in Eclipse?

I am trying to build my custom-commands in Eclipse.
This is Eclipse plugin which I am using: https://marketplace.eclipse.org/content/startexplorer
It looks like this (link to image):
Custom commands in Eclipse
I need eclipse variables in custom commands:
${resource_loc} , ${selected_resource_loc} , ${workspace_loc} , etc...
It should be something like this:
D:\cygwin64\bin\mintty.exe /bin/bash -l -c "cd ${workspace_loc}"
But mintty will close this window immediately. I need to execute command based on eclipse variable and go to bash interactive mode, without closing window.
To create a StartExplorer custom command, that opens a Cygwin terminal and
starts an interactive Bash shell in the filesystem location of the selected
resource, follow these steps:
Make sure to install chere
Cygwin package;
Install StartExplorer
Eclipse plugin;
In Eclipse Preferences for plugin StartExplorer, create a new custom
command:
Command: D:\cygwin64\bin\mintty.exe -e /bin/xhere /bin/bash
"${selected_resource_loc}"
Enabled for Resources: yes
Name for Resources Menu: Cygwin Bash Here
Resource Type: Folders
Alternatively to steps 2 and 3, if you don't care about context-menu entry, no
need to install the StartExplorer plugin.
Eclipse Extenal Tools Configuration standard feature will do the trick.
In Run > Extenal Tools Configuration, create a new Program:
Name: Cygwin Bash Here
Location: D:\cygwin64\bin\mintty.exe
Arguments: -e /bin/xhere /bin/bash "${selected_resource_loc}"
Basically, the xhere script (part of chere package) performs the following steps:
indicate to the login shells not to cd $HOME (export CHERE_INVOKING=true, which is checked for in /etc/profile);
change to the directory passed as 2nd argument (cd "$2");
Execute the shell passed as 1st argument as a login shell (exec -l $1).
Note: if you replace /bin/bash with /etc/passwd, the current user's login shell read from /etc/passwd is used instead of bash.

Chmod u+x windows cmd

I'm trying to install Scalatra on windows seven and need to change a file to executable...the Scalatra documentation says to do this, which is unix. What is the windows equivalant?
chmod u+x srt
You can simply open the relevant folder with a unix command prompt (I use git bash) and execute the unix commands from there
To get scalatra-sbt going on Windows, either port you own sbt.bat from scalatra-sbt, or install chmod via cygwin.
Assuming you've successfully installed the rest of Conscript and giter8, you can start a project that downloads scalatra-sbt. From there, one can look through the ./sbt source, and port the bash script functionality to your own windows specific script, or install a unix compatibility layer into Windows. If you go down the "windows specific script" route, perhaps the scalatra-sbt would appreciate the project contribution.
The "unix compatibility layer" route will eventually allow you to run ./sbt. chmod is a unix command line function, and is provided in a default package of the tool set cygwin, which provides a complete lunix-like environment. Once inside a cygwin terminal, you can chmod your file, as mentioned in the scalatra-sbt first project.
Diving into the contents of ./sbt from scalatra-sbt, this is actually unix script wrapper around the scala build tool (also referred to, confusingly, as sbt). If while trying to run ./sbt you get strange '\r' errors, install the cygwin package dos2unix, and then run it on the sbt file. If you run into any "which: no curl in..." or "which: no wget in..." errors, go back to the cygwin installer, find those packages such as wget, and then install those programs.
By the way, the last thing the scalatra-sbt script runs is the Scala build tool. The Scala build tool sbt itself has many reported issues with cygwin's default configuration, so you will likely need to do more research. Depending on what issues you're running into on your specific setup, you may need to make changes to the end of the ./sbt script to adjust the parameters used to launch the Scala build tool.

Eclipse PyDev use remote interpreter

is there a posibility to make eclipse PyDev use a remote Python interpreter?
I would like to do this, as the Linux Server I want to connect to has several optimization solvers (CPLEX, GUROBI etc.) running, that my script uses.
Currently I use eclipse locally to write the scripts, then copy all the files to the remote machine, log in using ssh and execute the scripts there with "python script.py".
Instead I hope to click the "run" button and just have everything executed within my eclipse IDE.
Thanks
Unfortunately no. You can remotely connect to your Linux server via Remote System Explorer (RSE). But can't use it as a remote interpreter. I use Pycharm. You can use the free Community Edition or the Professional Edition for which you have to pay for it. It is not that expensive and it has been working great for me.
As Adel says, this is probably not possible with the Remote System Explorer, or the normal Run button,
but you can automate the process you currently use. I had to do this for a few weeks when the fan was broken
in my laptop, and doing any significant computation there made it overheat and poweroff, so I just ran
everything on my work machine.
You can use the External Tools mechanism to run a short script that syncs your code to the remote server,
runs your script, then syncs back any output files to your local machine. My script looks like this,
is stored in $HOME/bin/runremote.sh, and is executable (chmod +x runremote.sh)
fp="$1" # Local path to the script we want to run--for now,
# this is the only command I pass in from Eclipse, but you could add others if so inclined.
# My home directory is a little different on my local machine than on the remote,
# but otherwise things are in the same place. Adjust as needed.
fp=`python -c "print '$fp'.replace('/home/tsbertalan', '/home/oakridge/bertalan')"`
# Run the synchronization. I use Unison, but you could use something else,
# like two calls to rsync, or a series of scp commands.
reposync >/dev/null # The redirection assumes your sync command will print errors properly on stderr.
cd='cd '`dirname $fp`
# I use a virtual environment on the remote server, since I don't have root access to install
# packages globally. But this could be any set-up command you want to run on the remote.
# A good alternative would be `source $HOME/.profile` or `~/.bashrc`.
act='source /home/oakridge/bertalan/bin/activate'
fname="`basename $fp`"
cmd="$act ; $cd ; python $fname"
# Run the command remotely. The -X forwards X11 windows, so you can see your Matplotlib plots.
# One difficulty with this method is that you might not see all your output just as it is created.
ssh bertalan#remote.server.edu -X "$cmd"
sleep 1
# My synchronization script is bidirectional, but you could just use rsync with the arguments flipped.
reposync >/dev/null
If you don't use linux or OSX locally, you'll probably have to use MinGW or Cygwin or whatever to get
this working. Or, since you appear to have a working Python interpreter, you could write an
equivalent script in Python, make it executable (by the file properties dialog in Explorer, I think),
and add a #!/path/to/python line at the top. I don't use Windows regularly, so I can't really help with that.
To use this in Eclipse, go to Run > External Tools > External Tools Configurations.... Add a new tools
whose Location is the path to your script, and whose first Argument is ${resource_loc}.
You can then use it with Run > External Tools > [first item], or bind it to a keyboard shortcut (I used F12)
by going to Windows > Preferences > Keys, and searching for "Run Last Launched External Tool". Presumably you'll
have to go through the menus first to make this the "Last Launched" external tool.

Configuring Eclipse for ROS

I am new to Linux. I am trying to develop ROS application using eclipse. I don't understand the below which is provided in ROS website. Can you explain this in more simple way, So that I can configure my eclipse after downloading from eclipse.org.
Reusing your shell's environment
For building and running ROS programs from inside IDEs, the ROS
enviroment has to be set up. All IDEs might have a config for that,
but running your IDE from your ROS-sourced shell should be the easiest
way, avoiding inconsistency.
Likewise, you can enhance your IDE's launcher icon to load your shells
environment. E.g., replace its command eclipse with
bash -i -c "eclipse". This will make bash source
~/.bashrc, in which ROS has to
be sourced and parameterized, and start that IDE.
use following commands:
cd <your_catkin_workspace>
catkin_make --force-cmake -G"Eclipse CDT4 - Unix Makefiles"
cd build
cmake ../src -DCMAKE_BUILD_TYPE=Debug
now you can import your project to eclipse
after that you can create a desktop application entry for eclispe:
sudo vim /usr/share/applications/eclipse.desktop
[Desktop Entry]
Type=Application
Terminal=false
Icon=<path_to_your_eclipse_dir>/icon.xpm
Exec=bash -i -c "source /opt/ros/hydro/setup.bash && source $HOME/workspace/<your_catkin_workspace>/devel/setup.bash && <path_to_your_eclipse_dir>/eclipse"
Comment=IDE
Name=eclipse
Comment=IDE
It seems that a wiki was published about this subject here
Put simply, the lines you listed are suggesting you run your IDE (eclipse) from a terminal which has already been sourced. So for instance, if you have a package called mypackage, you might type in a terminal:
cd ~/mypackage
source devel/setup.bash
eclipse
The first line is just however you get to your package, the second line sets up environmental variables for you (like changing your PATH), then you can run eclipse with all of those already setup so you don't have to configure your package in eclipse 100% manually.