On opening my terminal I get Virtualenvwrapper.sh file not found - virtualenv

I am using Mac and I installed virtualenv and virtualenvwrapper a long time ago using pip. I was using vitualenv alone most of the times. Recently I was trying to edit my .bash_profile and after that whenever I open my terminal I get the following error
"-bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory"
My .bash_profile
1 #export PS1="\u#\h\w: "
2 # Setting PATH for Python 2.7
3 # The orginal version is saved in .bash_profile.pysave
4 PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
5 export PATH
6
7 [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
8
9 # Setting PATH for Python 2.7
10 # The orginal version is saved in .bash_profile.pysave
11 PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
12 PATH="/usr/local/bin":$PATH
13 export PATH
14
15 export CLICOLOR=1
16 export LSCOLORS=ExFxCxDxBxegedabagacad
17
18 #source "/usr/bin/virtualenvwrapper.sh"
19 #export WORKON_HOME="/opt/virtual_env/"
20
21 #Randomly taken from stackoverflow post
22 export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
23 export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
24 source /usr/local/bin/virtualenvwrapper.sh
25
26 # h is the host name, w the complete path
27 export PS1="\w$ "
my .bashrc looks like this
1 #export PS1="\u#\h\w: "
2 PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
3
4 ### Added by the Heroku Toolbelt
5 export PATH="/usr/local/heroku/bin:$PATH"
6
7 export WORKON_HOME=$HOME/.virtualenvs
8 export PROJECT_HOME=$HOME/Devel
9 ##source /usr/local/bin/virtualenvwrapper.sh
10 source /Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenvwrapper.sh
11
12 # h is the host name, w the complete path
13 #export PS1="\w$ "
Can any one tell me where I am going wrong?
What is the difference between .bashrc an .bash_profile?
Thank you in advance.

Related

Read .mat files from Unix shell

Is there a way to read .mat files from the UNIX command line shell?
Such as cat mymat.mat ?
I am aware of the possibilities to load it in MATLAB or python, but these are not available for me atm.
GNU Octave may be an option as it can be freely installed without cost.
Say you ran a session something like this and created two arrays, A and B:
octave:1> A = [ 1:3; 4:6; 7:9 ];
octave:2> B = [ 11:13; 14:16; 17:19 ];
octave:3> save -7 myfile.mat A B
Then, in the shell, outside of Octave, you could do this to see the names of the variables in the file:
$ octave-cli <<< "who -file myfile.mat"
Sample Output
Variables in the file myfile.mat:
A B
And then this to dump the variables:
$ octave-cli <<< "load myfile.mat;A"
Sample Output
A =
1 2 3
4 5 6
7 8 9
And:
$ octave-cli <<< "load myfile.mat;B"
Sample Output
B =
11 12 13
14 15 16
17 18 19
No. .mat-files are saved in a binary format. You will not be able to interpret their content from the UNIX shell.

How to execute a unix executable file with Swift

I developing a OS X application with swift. I need to use some library on my application. The library is a Unix executable file.
I can execute the Unix executable file on terminal.
This is example:
pngquant --quality=65-80 test.png
But I need execute the Unix executable file on OS X application. I don't know how to do it.
I think should execute command on OS X application, and find an awesome library to execute the command.
Using swiftline example:
let result = run("ls -all")
print(result.stdout)
Print content:
total 0
drwxr-xr-x 6 DevinShine staff 204 Dec 23 22:18 .
drwxr-xr-x# 3 DevinShine staff 102 Dec 23 22:16 ..
drwxr-xr-x 3 DevinShine staff 102 Dec 23 23:25 Pion.app
drwxr-xr-x 4 DevinShine staff 136 Dec 23 22:18 Pion.swiftmodule
drwxr-xr-x 7 DevinShine staff 238 Dec 23 22:18 Pods.framework
drwxr-xr-x 7 DevinShine staff 238 Dec 23 22:18 Swiftline.framework
I copy Unix executable file to Build Phases.
But I don't know how to move Unix executable file to OS X application and execute it.
Please help me,thx.
I resolved it. The way is easy.
I run my application and execute run("pwd")
let result = run("pwd")
print(result.stdout)
let fullPath = result.stdout + "/Pion.app/Contents/MacOS/pngquant"
print content:
/Users/apple/Library/Developer/Xcode/DerivedData/Pion-ebbvaypzstbbordxhgeutzopihtt/Build/Products/Debug
excute pngquant function:
run(fullPath + " /Users/apple/Documents/test.png")
Update at 2015-12-25
NSBundle.mainBundle().executablePath will give you the path to your .app wrapper, so code is very clear.
run(NSBundle.mainBundle().executablePath + "pngquant /Users/apple/Documents/test.png")

In Solaris server with Putty, unable to delete copied file with some irregular special character

I use putty to log in to a solaris server. while i was performing a copy operation I pressed left arrow key to edit the file name but it kept adding this character ^[[D desperate I pressed return key and the copy operation got complete
cp temp.jar temp.jar^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D
I was planning to rename is as temp.jar.test, I used 'ls' command to check what has happened and to my surprise two files came up with same name!
root[dev1]# ls -lt temp*
-rw-r--r-- 1 root other 488554 Apr 11 02:25 temp.jar
-rw-r--r-- 1 root other 488554 Apr 11 02:22 temp.jar
-rw-r--r-- 1 root other 488554 Apr 11 02:22 temp.jar.041114
-rw-r--r-- 1 root other 488487 Sep 30 2013 temp.jar.032514
and I used 'rm' command to delete, the original file got deleted but the file copied with ^[[D character is not getting deleted. And I'm getting a msg like 'eisvr.jar.: No such file or directory'
Help me delete the file. I tried issuing 'rm temp.jar^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D'. It resulted in more errors.
The simplest way would be to run this command:
rm -i temp.jar?????????*
and answer yes when prompted to remove the bogus one.

Regarding Perl DBD::Oracle installation in local directory

I want to connect with the oracle database from a perl script in solaris servier. Able to see DBI is installed but not DBD::Oracle in the current perl version 5.8.4. I dont have root acess and working on my home user id. Download the DBD-Oracle-1.50 and unzipped in the local directory where my perl script exists. I want to copy the DBD Oracle library files into a custom directory and run the script since i dont have root acess. When i read the install script in the DBD-Oracle-1.50 it's says for manuall install i need to run the below scripts . Since i dont have root access i want to copy the library modules into the local directory. Not sure how to tell these scripts to install it in the local directory where my perl script exists.
Does installing DBI and DBD in a custom directory under my user id makes it work properly. Do those modules require root access to work properly? To use DBD::Oracle does oracle needs to be installed in server. My Understanding Oracle driver DBD::Oracle should take care of it.
perl Makefile.PL
make && make test
make install
> ls -tlr /usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int total 956
> -rwxr-xr-x 1 root bin 15161 Mar 26 2005 Roadmap.pod
> -rwxr-xr-x 1 root bin 1048 Sep 5 2006 TASKS.pod
> -rwxr-xr-x 1 root bin 289343 Jun 26 2007 DBI.pm
> -rwxr-xr-x 1 root bin 4608 Jun 12 2008 goferperf.pl
> -rwxr-xr-x 1 root bin 1356 Jun 12 2008 dbixs_rev.pl
> -rwxr-xr-x 1 root bin 58386 Apr 3 2010 SNMP.pm drwxr-xr-x 3 root bin 7 Oct 13 2010 NetSNMP
> drwxr-xr-x 2 root bin 3 Oct 13 2010 Win32 drwxr-xr-x
> 8 root bin 19 Oct 13 2010 DBI drwxr-xr-x 2 root
> bin 4 Oct 13 2010 Bundle drwxr-xr-x 6 root other
> 6 Oct 13 2010 auto drwxr-xr-x 3 root bin 11 Oct 13
> 2010 DBD
>
> ls -ltr /usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int/DBD total 543
> -rwxr-xr-x 1 root bin 111586 May 6 2006 Pg.pm
> -rwxr-xr-x 1 root bin 28785 Sep 27 2006 Proxy.pm
> -rwxr-xr-x 1 root bin 7937 Jan 25 2007 Sponge.pm
> -rwxr-xr-x 1 root bin 42836 Feb 6 2007 DBM.pm
> -rwxr-xr-x 1 root bin 19882 Mar 28 2007 File.pm
> -rwxr-xr-x 1 root bin 12051 May 10 2007 ExampleP.pm
> -rwxr-xr-x 1 root bin 43586 May 14 2007 Gofer.pm
> -rwxr-xr-x 1 root bin 3761 Jun 15 2007 NullP.pm drwxr-xr-x 4 root bin 4 Oct 13 2010 Gofer
If DBI is already installed, you should only need to install DBD::Oracle, though you might want to install a later version of DBI. You can install DBD::Oracle under your home directory, then set the PERL5LIB environment variable to that directory (or to include that directory). The long way to install is:
perl Makefile.PL PREFIX=~/perl #Or whatever sub-directory you like
make
make test
make install
Then include at least "~/perl/lib;~/perl/lib/site_perl" in PERL5LIB before running your programs (or include a 'use lib" in your programs).
You can also set certain environment variables like PERL_MM_OPT and PERL_MB_OPT so that you don't have to specify the PREFIX= on the command line (see docs for ExtUtils::MakeMaker and Module::Build). I also recommend cpanm and setting PERL_CPANM_HOME to something under your home directory.
Perl modules can be very well installed in a custom directory. This situation usually arises when you don't have root access to install the PM. Once you have installed DBI and DBD in your custom folder there are several different ways to make sure that perl is aware of this installation.
1. Set the environment variable PERL5LIB
Perl will look for modules in the directories specified in PERL5LIB environment variable before looking in the standard library and current directory, so you can set this variable to locate your modules.
The syntax is the same you use for the PATH environment variables, so you separate the directories with colons on unix and with a semicolon on Windows.
Example:
# unix, bourne shell
PERL5LIB=/home/path/lib:/usr/another/path/lib; export PERL5LIB
Be aware that scripts running with -T option (taint checks) do not use that variable, so in those cases this option won't work.
2. Use '-I' command line parameter
The syntax should be something like:
perl -I /home/path/lib -I /usr/another/lib script.pl
3. Add the library path in your script
The command for including the path in your script is: use lib "path".
Notice that this statement prepends "path" to the #INC array, so it's basically the same as unshift #INC, "path"
Example:
#!/usr/bin/perl
use lib "/home/path/lib";
use lib "/usr/another/lib";

Can't get launchd to work at Startup/Shutdown on OS X Lion

I followed some online guides trying to get some headless VMs to start/suspend automatically at boot/shutdown on my Mac. I can't get it to work at all. This is my first time trying to get script runs on Startup/Shutdown, so it could be that I'm just missing something very basic and if that's the case I apologize.
These are the steps I followed:
Created a directory /Library/StartupItems/HeadlessVM
Created two files within that directory:
-rwxr--r-- 1 root wheel 242 Feb 19 19:05 HeadlessVM
-rw-r--r-- 1 root wheel 188 Feb 20 12:42 StartupParameters.plist
Contents for HeadlessVM
$ cat HeadlessVM
#!/bin/sh
. /etc/rc.common
StartService ()
{
ConsoleMessage "Starting HeadlessVM"
/usr/local/bin/runvmheadless
}
StopService ()
{
ConsoleMessage "Suspending HeadlessVM"
/usr/local/bin/suspendvmheadless
}
RunService "$1"
Contents for StartupParameters.plist
$ cat StartupParameters.plist
{
Description = "Runs/Suspends Virtual Machine Headless on OS X Startup/Shutdown";
Provides = ("HeadlessVM");
Uses = ("Disks");
OrderPreference = ("Late");
}
Created my script files, that will perform both actions:
-rwxr-xr-x# 1 xxxxxxx admin 164 Feb 19 01:06 runvmheadless
-rwxr-xr-x# 1 xxxxxxx admin 160 Feb 19 01:19 suspendvmheadless
Contents for runvmheadless
$ cat runvmheadless
#!/bin/bash
"/Applications/VMware Fusion.app/Contents/Library/vmrun" -T fusion start "/Volumes/Archive/Virtual Machines/vm.vmwarevm/vm.vmx" nogui
Contents for suspendvmheadless
$ cat suspendvmheadless
#!/bin/bash
"/Applications/VMware Fusion.app/Contents/Library/vmrun" -T fusion suspend "/Volumes/StaticData/Virtual Machines/vm.vmwarevm/vm.vmx"
My troubleshooting so far:
If I run the scripts from the terminal, they work as intended.
If I run sudo /sbin/SystemStarter (start or stop) "HeadlessVM" it also works.
On console I only see the following when I reboot, no clue on what's wrong tho.
2/20/12 12:11:09.128 PM SystemStarter: Runs/Suspends Virtual Machine Headless on OS X Startup/Shutdown (100) did not complete successfully
Appreciate any help, Thank you.
I found what was wrong. The code above is fine, the problem is that my scripts are trying to get data from an encrypted secondary disk which was not available at boot time.
I used this in order to bypass this problem:https://github.com/jridgewell/Unlock
Thanks