Archive for bash

[tekwalk] xopen : shell function to have verbose xdg-open : Mac’s “open” alternative for Linux

Posted in AbhishekKr, Blogroll, install-on-linux with tags , , , , , , , on March 4, 2014 by abhishekkr

tekwalk.blogspot.in [13/Feb/2014]

http://tekwalk.blogspot.in/2014/02/xopen-shell-function-to-have-verbose.html

I have been using xdg-open for sometime now, it’s a utility similar to “open” utility popular among MacOSx users.

It enables you to open any file in the default “open with” program assigned to it’s type. So, just passing any type of file to this utility would let you open it in the program it’s supposed to open.

What is xdg-open?
source[1]: https://wiki.archlinux.org/index.php/xdg-open
source[2]: http://linux.die.net/man/1/xdg-open

There is just this little shell function, that makes your xdg-open usage a bit more verbose in case of errors (bad-syntax/ghost-file/ghost-program/open-failure) faced about the reason for it. And also shortens the access util name obviously.

xopen ()
{
xdg-open “$@”;
_TMP_EXITCODE=$?;
if [ “${_TMP_EXITCODE}” == “1” ]; then
echo “[ERROR:] Error in command line syntax”;
else
if [ “${_TMP_EXITCODE}” == “2” ]; then
echo “[ERROR:] One of the files passed on the command line did not exist”;
else
if [ “${_TMP_EXITCODE}” == “3” ]; then
echo “[ERROR:] A required tool could not be found”;
else
if [ “${_TMP_EXITCODE}” == “4” ]; then
echo “[ERROR:] The action failed”;
fi;
fi;
fi;
fi;
return $_TMP_EXITCODE
}

…read full blogpost here

Advertisements

[tekwalk] Fabric (py orchestration util) issue with my FreeBSD node, and Easy Fix

Posted in Blogroll, tutorial with tags , , , , on September 22, 2013 by abhishekkr

@ tekwalk.blogspot.in [12/Aug/2013]

http://tekwalk.blogspot.in/2013/08/fabric-py-orchestration-util-issue-with.html

Recently…..

The way Fabric works is whatever you ask it to “run(<cmd>)” over remote nodes, it runs that command by passing it to ” bash -l -c ‘<cmd>’ “.
Now as the issue was with my FreeBSD machine is it didn’t had “bash” in the first place. So, it was failing.
It can be fixed in 2 ways
First way,
add a line like following to make Fabric use the SHELL present on the remote node, as FreeBSD node had ‘C Shell’… so

env.shell = ‘/bin/csh -c’

Second way,
install ‘bash’ on the remote nodes and make sure it’s reachable via path “/bin/bash”

pkg_add -r bash

ln -sf /usr/local/bin/bash /bin/bash

…..click here to read full post