Changes to point to the New Ant - ant

I have a newer ANT in /usr/local/ant .... when did "which ant" it showed me that its still pointing to the default ANT "usr/bin/ant" installed with the Centos 5.8. How do i change it ?
Have tried the following changes, but no luck:
export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/lib/jvm/java
export PATH=$PATH:/usr/local/ant/bin
export CLASSPATH=.:$JAVA_HOME/lib/classes.zip
echo 'export ANT_HOME=/usr/local/ant' >> /etc/bashrc
echo 'export JAVA_HOME=/usr/lib/jvm/java' >> /etc/bashrc
echo 'export PATH=$PATH:/usr/local/ant/bin' >> /etc/bashrc
echo 'export CLASSPATH=.:$JAVA_HOME/lib/classes.zip' >> /etc/bashrc

Put your valid path as a first one in PATH environment variable:
export PATH=/usr/local/ant/bin:$PATH
See this article for more details.

Related

extraneous end if in .dep.inc file

I am giving a job to Jenkins to build binaries for my code through make file . It is showing error of extraneous end if in .dep.inc file,I tried to change the configuration of net beans.
This file is getting generated from auto generated make file in net beans. In net beans it is compiling but in Jenkins it is showing error.*
# dependency checking support
.depcheck-impl:
#echo "# This code depends on make tool being used" >.dep.inc
#if [ -n "${MAKE_VERSION}" ]; then \
echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
echo "include \$${DEPFILES}" >>.dep.inc; \
echo "endif" >>.dep.inc; \
else \
echo ".KEEP_STATE:" >>.dep.inc; \
echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
fi
you are using BASH syntax instead of Makefile. One option could be to use the conditional structure of Makefile:
Conditional Parts of Makefiles
Another way is to define the whole BASH instruction in the same line, like that:
if [ <condition>]; then <action1>; else <action2>; fi
In Makefile, each line of a target could be a SHELL, but you should not split them.
Finally, you can use the "define" environment to insert BASH code:
define <name>=
<BASH code>
<...>
<name>: ; #$(value <name>)
.ONESHELL
I hope you find it useful!

ROS how to find all executables of a package?

I want to ask how to find all the executable names of a package in ROS (Robot Operating System)? For example, find spawn_model in gazebo_ros package. When I inspect the package in my system, it just shows some .xml, .cmake files, without any executables. But I can run it, such as: rosrun gazebo_ros spawn_model.
Thank you!
An easy way to do this is to type: "rosrun name_of_package " and then press tab two times, it should show you all the executables built.
After looking in the bash autocompletion script for rosrun, it looks like the command catkin_find is used to find the location of the executables for a package, and the executables are filtered with a find command.
If you want to create a script to give you a list of the executables follow the instructions below:
Save the following script in a file called rospack-list-executables:
#!/bin/bash
if [[ $# -lt 1 ]]; then
echo "usage: $(basename $0) <pkg_name>"
echo ""
echo " To get a list of all package names use the command"
echo " 'rospack list-names'"
exit
fi
pkgname=${1}
pkgdir="$(catkin_find --first-only --without-underlays --libexec ${pkgname})"
if [[ -n "${pkgdir}" ]]; then
find -L "${pkgdir}" -executable -type f ! -regex ".*/[.].*" ! -regex ".*${pkgdir}\/build\/.*" -print0 | tr '\000' '\n' | sed -e "s/.*\/\(.*\)/\1/g" | sort
else
echo "Cannot find executables for package '${pkgname}'." >&2
exit 1
fi
Then make the rospack-list-executables script executable (chmod +x rospack-list-executables) and place it in a directory that can be found in your $PATH environment variable.
Run the script:
$ rospack-list-executables gazebo_ros
debug
gazebo
gdbrun
gzclient
gzserver
libcommon.sh
perf
spawn_model
You should get the same result that you get when you type the rosrun <pkgname> command and press Tab:
$ rosrun gazebo_ros
debug gazebo gdbrun gzclient gzserver libcommon.sh perf spawn_model
You can check the executables for all packages with the following bash code:
rospack list-names | while read pkgname; do
echo "Executables for package '${pkgname}':";
rospack-list-executables $pkgname; echo "";
done
To enable package autocompletion for your newly created command, type the following:
complete -F _roscomplete rospack-list-executables
If you do not want to have to type the complete command every time you login, you can append it to your .bashrc file:
echo "complete -F _roscomplete rospack-list-executables" >> ~/.bashrc
Now when you type the command rospack-list-executables and press the Tab key, you should get a list of all the available packages to choose from.
catkin_find --first-only --without-underlays --libexec <your package name>)
should give you the folder where the executables are

Nim(rod) not installing to path properly?

I'm following the isntructions for installing Nim(rod) onto linux. I then followed this site which showed to do this:
$ echo 'export PATH=$PATH:$your_install_dir/bin' >> ~/.profile
$ source ~/.profile
$ nim
Typing nim in the terminal doesn't do anything.
I have a Nim folder in my home directory with all the files but can't use it.
I did echo export PATH=$PATH:$/home/bob/Nim/bin' >> ~/.profile
And the nim command still does nothing. Am I not doing it right?
The command pwd told me /home/bob/Nim when I was in the Nim folder.
I tried running nim with sh in Nim/bin and did ./nim -path:/home/bob/Nim/bin
and it said:
config/nim.cfg(45, 2) Hint: added path: '/home/bob/.babel/pkgs/' [Path]
config/nim.cfg(46, 2) Hint: added path: '/home/bob/.nimble/pkgs/' [Path]
Hint: used config file '/home/bob/Nim/config/nim.cfg' [Conf]
echo 'export PATH=$PATH:$/home/bob/Nim/bin' >> ~/.profile
You appended the location $/home/bob/Nim/bin which doesn't exist. You must remove the $.

How can I avoid certain lines from .bashrc and .inputrc from being loaded in tmux?

I have these lines in my .inputrc:
"(": "\C-v()\ei"
"[": "\C-v[]\ei"
"{": "\C-v{}\ei"
"\"": "\C-v\"\C-v\"\ei"
"\'": "\C-v\'\C-v\'\ei"
This autocloses quotes and brackets in a terminal. But it causes an inconvenience in a tmux session: when I send text containing quotes to frome one pane (vim) to another pane (bash / python / R etc), every quote is turned into two, very annoying.
Is it possible to disable these lines in (and only in) tmux?
tmux sets the TMUX environment variable, so in .bashrc (or .profile or whatever):
if [ '' = "$TMUX" ] ; then
echo not in TMUX
else
echo in TMUX
fi
You can set INPUTRC to override the default .inputrc location, so you could have a tmux one and a non-tmux one, and export a suitable INPUTRC value in .bashrc depending on TMUX. You could even concoct a suitable .inputrc (e.g. in /tmp) for that session based on a "common" file and a "non-tmux session" file.
Unfortunately tmux exports TMUX, and so subshells started from a tmux session will have TMUX set regardless. Not found a way round that yet.
I ended up doing this in ~/.bashrc:
if [[ '' = "$TMUX" ]]
then
set -o vi
bind -m vi-insert '"(" "\C-v()\ei"'
bind -m vi-insert '"[" "\C-v[]\ei"'
bind -m vi-insert '"{" "\C-v{}\ei"'
bind -m vi-insert '"\"" "\C-v\"\C-v\"\ei"'
bind -m vi-insert '"\047" "\C-v\047\C-v\047\ei"'
else
echo Welcome to Tmux!
fi
UPDATE
Adopting user3392484 's suggestion, I found this much better:
if [[ '' = "$TMUX" ]]
then
export INPUTRC=~/.inputrc
else
export INPUTRC=~/.tmux.inputrc
echo Welcome to Tmux!
fi

How can I find the location of the tcsh shell script I'm executing?

Say I put an executable tcsh file in /path/to/my_script.csh
and my current directory is anywhere, for example I'm in /path
So I type to/my_script.csh
I want to have a line in my_script.csh that will return "/path/to/my_script.csh" - like ruby's
__FILE__
In c shell, try like this:
set rootdir = `dirname $0`
set abs_rootdir = `cd $rootdir && pwd`
echo $abs_rootdir
If you want to ensure the same result (full path and script name) try something like this:
...
rootdir=`/bin/dirname $0` # may be relative path
rootdir=`cd $rootdir && pwd` # ensure absolute path
zero=$rootdir/`/bin/basename $0`
echo $zero
...
Then you can call it as foo.sh, ./foo.sh, some/lower/dir/foo.sh and still get the same result no matter how it is called.
If you want an absolute path then this should help you out:
#!/bin/tcsh -f
set called=($_)
if ( "$called" != "" ) then ### called by source
echo "branch 1"
set script_fn=`readlink -f $called[2]`
else ### called by direct execution of the script
echo "branch 2"
set script_fn=`readlink -f $0`
endif
echo "A:$0"
echo "B:$called"
set script_dir=`dirname $script_fn`
echo "script file name=$script_fn"
echo "script dir=$script_dir"
Source: http://tipsarea.com/2013/04/11/how-to-get-the-script-path-name-in-cshtcsh/
#!/bin/tcsh
echo "I am $0."

Resources