---
author:
  email: rkitover@io.com
  keyid: ecfd90663e4a2921
  name: Rafael Kitover
categories: []
date: 2012-01-30T19:50:33Z
guid: D3A2EE3C-4B7B-11E1-8F51-0E3521E7A903
modified: 2012-01-31T11:30:37Z
raw: "-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\n=pod\n\nHere I will describe
  how to do scheduled automatic backups to an external hard\ndrive on a Debian/Ubuntu
  Linux computer with the\nL<Back In Time|http://backintime.le-web.org/> system.\n\nFirst
  install the package:\n\n  lang:bash\n  sudo aptitude install backintime-gnome\n\n=head2
  Preparing the Hard Drive\n\nPlug in your USB/ESATA/FireWire hard drive into your
  linux computer, then do a:\n\n  lang:bash\n  dmesg | tail\n\nto note the block device,
  such as C</dev/sdd>.\n\nNext you will want to partition it. Use C<cfdisk> or C<gparted>.\n\nMake
  one primary partition of type C<Linux> (C<83>) that is the size of the\ndrive.\n\nNext
  format it with your favorite file system.\n\nUse a command such as:\n\n  lang:bash\n
  \ sudo mkfs.ext4 /dev/sdd1\n\nNow let's mount it. We are going to mount it under
  C</media> so that the\nC<updatedb> cron job does not index it and clutter your locate
  db with your\nbackup files. We are also going to mount it by UUID so that the order
  you plug\nin your devices, the presence of hubs, etc. does not affect mounting.\n\nFirst
  make the mount point:\n\n  lang:bash\n  sudo mkdir /media/backup\n\nThen get the
  UUID of the new partition:\n\n  lang:bash\n  sudo blkid /dev/sdd1\n\nNow add the
  mount point to /etc/fstab using the UUID from the previous step:\n\n  lang:fstab\n
  \ UUID=e3b623e7-2049-46cf-89aa-1152c38e08e8 /media/backup ext4 defaults,nofail\n\nNow
  mount it!\n\n  lang:bash\n  sudo mount /media/backup\n\nRemember to mount it when
  you plug your hard drive in.\n\nIf you know of a way to automount an fstab entry,
  please email me so I can add\nit here...\n\nWe are going to make the backup directory
  one level below the mount point so\nthat having the drive disconnected tells Back
  In Time to not run the backup job,\notherwise it would run the backup job on the
  root file system!\n\n  lang:bash\n  sudo mkdir /media/backup/snapshots\n\n=head2
  Setting up Back In Time\n\nNow you're ready to run the Back In Time configuration
  program. Run:\n\n  lang:bash\n  ssh -X root@localhost backintime-gnome\n\nClick
  the Settings button.\n\nFor \"Where to save snapshots\" select C</media/backup/snapshots>.\n\nFor
  \"Schedule\" I use \"Every Day\" at 03:00. Choose a time your machine is likely\nto
  be idle and the hard drive is likely to be plugged in.\n\nClick the Include tab.
  Add folders such as C</home> and C</etc> and any others\nyou want to back up.\n\nPress
  \"Ok\" and close the program.\n\nPress Ctrl-C to close the ssh session.\n\nAnd you're
  done!\n\nI also highly recommend installing anacron:\n\n  lang:bash\n  sudo aptitude
  install anacron\n\nespecially on a laptop, because Back In Time runs from cron.
  This way if your\nlaptop is off or asleep when the job is supposed to run, your
  backup will still\nrun at some future time.\n\n=head2 Final Thoughts\n\nBackups
  can seriously save your arse. Hard drives and SSDs fail. Alot.\n\nNow Mac OS X and
  Windows have attractive built-in backup options, Time Machine\nand Windows Backup,
  respectively. Time Machine is unmatched in power and\nsimplicity. Windows Backup
  is not as shiny, but still does the job admirably.\n\nWith Back In Time, we now
  have a nice backup solution for Linux as well.\n\nEnjoy the comfort of knowing that
  your data is safe.\n\n=cut\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.11
  (GNU/Linux)\n\niQCVAwUBTyfQ2+z9kGY+SikhAQKcDwQA2wYuIYTiWu4NBEeUge1wM+JOf4BKD8WA\nUHcgaHKabodPzsxGu+9qLAbkuDnQTkp0HkMwl0bwAw1Uz0Zk2dAV4vjsKKitUaOd\npfA8m/LMBM/llsfzTzNdXRgS1ier5/qD2ulSZzfU4LpdNqCFrUw2a17m0PDVJjIe\nHXtqrh1Fdr4=\n=9fXP\n-----END
  PGP SIGNATURE-----\n"
signed: 1
summary: ' Here I will describe how to do scheduled automatic …'
tags:
- time-machine: 0
- backintime: 0
- backup: 0
- linux: 0
text: "    Here I will describe how to do scheduled automatic backups to an ex-\n
  \   ternal hard drive on a Debian/Ubuntu Linux computer with the Back In\n    Time
  <http://backintime.le-web.org/> system.\n\n    First install the package:\n\n      lang:bash
  sudo aptitude install backintime-gnome\n\n Preparing the Hard Drive\n\n    Plug
  in your USB/ESATA/FireWire hard drive into your linux computer,\n    then do a:\n\n
  \     lang:bash dmesg | tail\n\n    to note the block device, such as /dev/sdd.\n\n
  \   Next you will want to partition it. Use cfdisk or gparted.\n\n    Make one primary
  partition of type Linux (83) that is the size of\n    the drive.\n\n    Next format
  it with your favorite file system.\n\n    Use a command such as:\n\n      lang:bash
  sudo mkfs.ext4 /dev/sdd1\n\n    Now let's mount it. We are going to mount it under
  /media so that\n    the updatedb cron job does not index it and clutter your locate
  db\n    with your backup files. We are also going to mount it by UUID so\n    that
  the order you plug in your devices, the presence of hubs, etc.\n    does not affect
  mounting.\n\n    First make the mount point:\n\n      lang:bash sudo mkdir /media/backup\n\n
  \   Then get the UUID of the new partition:\n\n      lang:bash sudo blkid /dev/sdd1\n\n
  \   Now add the mount point to /etc/fstab using the UUID from the pre-\n    vious
  step:\n\n      lang:fstab UUID=e3b623e7-2049-46cf-89aa-1152c38e08e8 /media/backup\n
  \     ext4 defaults,nofail\n\n    Now mount it!\n\n      lang:bash sudo mount /media/backup\n\n
  \   Remember to mount it when you plug your hard drive in.\n\n    If you know of
  a way to automount an fstab entry, please email me so\n    I can add it here...\n\n
  \   We are going to make the backup directory one level below the mount\n    point
  so that having the drive disconnected tells Back In Time to\n    not run the backup
  job, otherwise it would run the backup job on the\n    root file system!\n\n      lang:bash
  sudo mkdir /media/backup/snapshots\n\n Setting up Back In Time\n\n    Now you're
  ready to run the Back In Time configuration program. Run:\n\n      lang:bash ssh
  -X root@localhost backintime-gnome\n\n    Click the Settings button.\n\n    For
  \"Where to save snapshots\" select /media/backup/snapshots.\n\n    For \"Schedule\"
  I use \"Every Day\" at 03:00. Choose a time your ma-\n    chine is likely to be
  idle and the hard drive is likely to be\n    plugged in.\n\n    Click the Include
  tab. Add folders such as /home and /etc and any\n    others you want to back up.\n\n
  \   Press \"Ok\" and close the program.\n\n    Press Ctrl-C to close the ssh session.\n\n
  \   And you're done!\n\n    I also highly recommend installing anacron:\n\n      lang:bash
  sudo aptitude install anacron\n\n    especially on a laptop, because Back In Time
  runs from cron. This\n    way if your laptop is off or asleep when the job is supposed
  to run,\n    your backup will still run at some future time.\n\n Final Thoughts\n\n
  \   Backups can seriously save your arse. Hard drives and SSDs\n    fail. Alot.\n\n
  \   Now Mac OS X and Windows have attractive built-in backup options,\n    Time
  Machine and Windows Backup, respectively. Time Machine is un-\n    matched in power
  and simplicity. Windows Backup is not as shiny, but\n    still does the job admirably.\n\n
  \   With Back In Time, we now have a nice backup solution for Lin-\n    ux as well.\n\n
  \   Enjoy the comfort of knowing that your data is safe.\n"
title: Linux Backup with Back In Time
type: pod
uri: http://blog.cachemiss.com/articles/Linux%20Backup%20with%20Back%20In%20Time.pod
xhtml: '<div class="pod">

  <p>Here I will describe how to do scheduled automatic backups to an external hard

  drive on a Debian/Ubuntu Linux computer with the

  <a href="http://backintime.le-web.org/">Back In Time</a> system.</p>

  <p>First install the package:</p>

  <pre><span class="BString">sudo</span><span class="Normal"> aptitude </span><span
  class="BString">install</span><span class="Normal"> backintime-gnome</span>

  </pre>

  <h4 id="Preparing_the_Hard_Drive">Preparing the Hard Drive</h4>

  <div id="Preparing_the_Hard_Drive_CONTENT">

  <p>Plug in your USB/ESATA/FireWire hard drive into your linux computer, then do
  a:</p>

  <pre><span class="BString">dmesg</span><span class="Normal"> </span><span class="Keyword">|</span><span
  class="Normal"> </span><span class="BString">tail</span>

  </pre>

  <p>to note the block device, such as <code>/dev/sdd</code>.</p>

  <p>Next you will want to partition it. Use <code>cfdisk</code> or <code>gparted</code>.</p>

  <p>Make one primary partition of type <code>Linux</code> (<code>83</code>) that
  is the size of the

  drive.</p>

  <p>Next format it with your favorite file system.</p>

  <p>Use a command such as:</p>

  <pre><span class="BString">sudo</span><span class="Normal"> mkfs.ext4 /dev/sdd1</span>

  </pre>

  <p>Now let''s mount it. We are going to mount it under <code>/media</code> so that
  the

  <code>updatedb</code> cron job does not index it and clutter your locate db with
  your

  backup files. We are also going to mount it by UUID so that the order you plug

  in your devices, the presence of hubs, etc. does not affect mounting.</p>

  <p>First make the mount point:</p>

  <pre><span class="BString">sudo</span><span class="Normal"> </span><span class="BString">mkdir</span><span
  class="Normal"> /media/backup</span>

  </pre>

  <p>Then get the UUID of the new partition:</p>

  <pre><span class="BString">sudo</span><span class="Normal"> blkid /dev/sdd1</span>

  </pre>

  <p>Now add the mount point to /etc/fstab using the UUID from the previous step:</p>

  <pre>UUID=e3b623e7-2049-46cf-89aa-1152c38e08e8 /media/backup ext4 defaults,nofail

  </pre>

  <p>Now mount it!</p>

  <pre><span class="BString">sudo</span><span class="Normal"> </span><span class="BString">mount</span><span
  class="Normal"> /media/backup</span>

  </pre>

  <p>Remember to mount it when you plug your hard drive in.</p>

  <p>If you know of a way to automount an fstab entry, please email me so I can add

  it here...</p>

  <p>We are going to make the backup directory one level below the mount point so

  that having the drive disconnected tells Back In Time to not run the backup job,

  otherwise it would run the backup job on the root file system!</p>

  <pre><span class="BString">sudo</span><span class="Normal"> </span><span class="BString">mkdir</span><span
  class="Normal"> /media/backup/snapshots</span>

  </pre>


  </div>

  <h4 id="Setting_up_Back_In_Time">Setting up Back In Time</h4>

  <div id="Setting_up_Back_In_Time_CONTENT">

  <p>Now you''re ready to run the Back In Time configuration program. Run:</p>

  <pre><span class="BString">ssh</span><span class="Normal"> -X root@localhost backintime-gnome</span>

  </pre>

  <p>Click the Settings button.</p>

  <p>For &quot;Where to save snapshots&quot; select <code>/media/backup/snapshots</code>.</p>

  <p>For &quot;Schedule&quot; I use &quot;Every Day&quot; at 03:00. Choose a time
  your machine is likely

  to be idle and the hard drive is likely to be plugged in.</p>

  <p>Click the Include tab. Add folders such as <code>/home</code> and <code>/etc</code>
  and any others

  you want to back up.</p>

  <p>Press &quot;Ok&quot; and close the program.</p>

  <p>Press Ctrl-C to close the ssh session.</p>

  <p>And you''re done!</p>

  <p>I also highly recommend installing anacron:</p>

  <pre><span class="BString">sudo</span><span class="Normal"> aptitude </span><span
  class="BString">install</span><span class="Normal"> anacron</span>

  </pre>

  <p>especially on a laptop, because Back In Time runs from cron. This way if your

  laptop is off or asleep when the job is supposed to run, your backup will still

  run at some future time.</p>


  </div>

  <h4 id="Final_Thoughts">Final Thoughts</h4>

  <div id="Final_Thoughts_CONTENT">

  <p>Backups can seriously save your arse. Hard drives and SSDs fail. Alot.</p>

  <p>Now Mac OS X and Windows have attractive built-in backup options, Time Machine

  and Windows Backup, respectively. Time Machine is unmatched in power and

  simplicity. Windows Backup is not as shiny, but still does the job admirably.</p>

  <p>With Back In Time, we now have a nice backup solution for Linux as well.</p>

  <p>Enjoy the comfort of knowing that your data is safe.</p>


  </div>

  </div>'
---
author:
  email: rkitover@io.com
  keyid: ecfd90663e4a2921
  name: Rafael Kitover
categories: []
date: 2011-09-24T10:11:55Z
guid: BB485A16-E695-11E0-8FCC-E4E720E7A903
modified: 2011-09-24T10:11:55Z
raw: "-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\n=pod\n\nHere I will go through
  the steps necessary to set up and use SQL Anywhere on Mac\nOS X.\n\n=head1 Download
  and Install SQL Anywhere\n\nIt is available here: L<http://www.sybase.com/detail?id=1016644>.\n\nOpen
  the package and double click the C<Install SQL Anywhere> icon, select all\ncomponents.\n\nAt
  the end click the C<Check for Updates> button, it will take you to the EBF\ndownload.
  You will need to create a MySybase account to download the EBF\npackage. Download
  the package, doubleclick the C<Install SQL Anywhere> icon and\nselect the C<update
  product> option.\n\n=head1 Set up Your User Environment\n\nAdd the following to
  your C<~/.bashrc>:\n\n  lang:bash\n  export SQLANYWHERE_HOME=/Applications/SQLAnywhere12/System\n
  \ export DYLD_LIBRARY_PATH=$SQLANYWHERE_HOME/lib64:$SQLANYWHERE_HOME/lib32:$DYLD_LIBRARY_PATH\n
  \ export DYLD_BIND_AT_LAUNCH=1\n  export PATH=$PATH:$SQLANYWHERE_HOME/bin64:$SQLANYWHERE_HOME/bin32\n\nFor
  the next step, open a new terminal session for the environment changes to\ntake
  effect.\n\n=head1 Create a Database\n\nExecute the following to create a new database:\n\n
  \ lang:bash\n  cd\n  mkdir sqlanywhere\n  cd sqlanywhere\n  mkdir logs\n  dbinit
  -t ./logs/hlaghdb.log -p 4096 -dba DBA,SQL hlaghdb.db\n\n=head1 Set up the Database
  Server\n\nCreate a file called C<~/Library/LaunchAgents/com.ianywhere.sqlanywhere.plist>,\nput
  the following in that file, changing C</Users/rkitover> to your actual home\ndirectory
  and the database file name to your actual database file:\n\n  lang:xml\n  <?xml
  version='1.0' encoding='UTF-8'?>\n  <!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD
  PLIST 1.0//EN\"\n  \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\" >\n  <plist
  version='1.0'>\n  <dict>\n  <key>Label</key><string>com.ianywhere.sqlanywhere</string>\n
  \ <key>WorkingDirectory</key><string>/Users/rkitover/sqlanywhere</string>\n  <key>EnvironmentVariables</key>\n
  \     <dict>\n          <key>DYLD_LIBRARY_PATH</key>\n          <string>/Applications/SQLAnywhere12/System/lib64:/Applications/SQLAnywhere12/System/lib32</string>\n
  \         <key>DYLD_BIND_AT_LAUNCH</key>\n          <string>1</string>\n      </dict>\n
  \ <key>ProgramArguments</key>\n  <array>\n          <string>/Applications/SQLAnywhere12/System/bin32/dbsrv12</string>\n
  \         <string>-ud</string>\n          <string>/Users/rkitover/sqlanywhere/hlaghdb.db</string>\n
  \ </array>\n  <key>Debug</key><false/>\n  <key>Disabled</key><true/>\n  <key>KeepAlive</key><true/>\n
  \ </dict>\n  </plist>\n\nB<NOTE:> we do not give the database server a name in this
  example. This is\nbecause for some reason when I tried to use C<-n> option to C<dbsrv12>
  it\nresponded with C<Communication error>. Try running C<dbsrv12> from the command\nline
  with the C<-n> option to see if it works for you, if it does add it to the\nC<ProgramArguments>
  in the C<.plist> file. E.g.:\n\n  lang:bash\n  dbsrv12 -ud -n SQLANYWHERE hlaghdb.db\n\nIf
  this works, add the following to the C<.plist> file after C<dbsrv12>:\n\n  lang:xml\n
  \ <string>-n</string>\n  <string>SQLANYWHERE</string>\n\nThe following examples
  will all assume the database server has no name.\n\nNow execute the following to
  load the service and start the database server:\n\n  lang:bash\n  launchctl load
  -w ~/Library/LaunchAgents/com.ianywhere.sqlanywhere.plist\n  launchctl start com.ianywhere.sqlanywhere\n\nYou
  should see the database server in ps:\n\n  lang:bash\n  $ ps aux | grep dbsrv\n
  \ rkitover       51654   0.3  0.2  1627072  14000   ??  Ss    1:02PM   0:03.07 /Applications/SQLAnywhere12/System/bin32/dbsrv12
  -ud /Users/rkitover/sqlanywhere/hlaghdb.db\n\nIt will be started across reboots.\n\nC<launchctl
  stop> doesn't work with this plist, so if you need to restart the\nserver, just
  kill the process and do a C<launchctl stop> followed by a\nC<launchctl start>.\n\n=head1
  The SQL Anywhere Applications\n\nOpen the C<SQLAnywhere12> folder under C<Applications>
  in Finder.\n\nThe applications we're interested in are C<Sybase Central> and C<Interactive\nSQL>.\n\nThe
  C<Sybase Central> application will allow you to configure all aspects of\nyour database.
  To use it, open the application, double click on the C<SQL\nAnywhere 12> plugin,
  right click inside the blank window and choose C<Connect>,\nchoose C<Connect to
  a running database on this computer>, enter the username and\npassword you used
  with the C<dbinit> command, which in this example is C<DBA>\nand C<SQL> respectively.\n\nThe
  C<Interactive SQL> application is a handy GUI for testing SQL statements on\nyour
  database. To login, open the application, choose C<Database>\nauthentication, choose
  C<Connect to a running database on this computer>, enter\nyour username and password
  and press C<Connect>. Inside the application, enter\nyour SQL statements in the
  SQL statements window and press C<F5> to execute\nthem; you will see your results
  in the results window.\n\n=head1 Using sqsh\n\nIf you would prefer a commandline
  utility to C<Interactive SQL> for testing SQL\nstatements, you can use the sqsh
  utility from MacPorts\n(L<http://www.macports.org/>.)\n\nThe C<sqsh> utility is
  an interactive SQL utility for databases using the TDS\nprotocol, such as Sybase
  ASE and Microsoft SQL Server. SQL Anywhere also uses\nthe TDS protocol, so the utility
  works for these databases as well.\n\nIf you do not yet have an C<interfaces> file,
  follow these steps to set one up.\n\nIn your C<.bashrc> add the following:\n\n  lang:bash\n
  \ export SYBASE=~/sybase\n\nIn this directory create a file called C<interfaces>
  with the following:\n\n  SQLANYWHERE\n    master tcp ether localhost 2638\n    query
  tcp ether localhost 2638\n\nNow you can launch C<sqsh> like so:\n\n  lang:bash\n
  \ sqsh -S SQLANYWHERE -U DBA -P SQL\n\nTo use it, type in a SQL statement, it can
  span multiple lines, then type C<go>\non a line by itself to execute it. This may
  take some getting used to if you're\nused to tools such as sqlplus or dbish, where
  SQL statements are terminated by a\nsemicolon. You can use dbish with SQL Anywhere
  as well, I will describe how to\ndo so further down.\n\n=head1 Setting up ODBC\n\nIf
  you have UnixODBC from MacPorts (L<http://www.macports.org/>,) you can set up\nthe
  included ODBC drivers with it.\n\nIn C</opt/local/etc/odbcinst.ini> add the following:\n\n
  \ lang:ini\n  [SQLAnywhere]\n  Description = SQL Anywhere\n  Driver = /Applications/SQLAnywhere12/System/lib64/libdbodbc12.dylib\n
  \ Setup = /Applications/SQLAnywhere12/System/lib64/libdbodbc12.dylib\n  FileUsage
  = 1\n\nNow lets test it out (take out the -S flag to cpanm if you use local::lib):\n\n
  \ lang:bash\n  curl -L http://cpanmin.us | perl - -S App::cpanminus\n  cpanm -n
  -S DBI\n  cpanm -n -S DBD::ODBC\n  perl -MDBI -le 'my $dbh = DBI->connect(\"dbi:ODBC:driver=SQLAnywhere\",
  \"DBA\", \"SQL\"); print for $dbh->selectrow_array(\"select 42\")'\n\n=head1 Installing
  the Perl Driver\n\nFirst install DBI:\n\n  lang:bash\n  curl -L http://cpanmin.us
  | perl - -S App::cpanminus\n  cpanm -n -S DBI\n\nThen build and install the Perl
  library:\n  \n  lang:bash\n  cp -a /Applications/SQLAnywhere12/sdk/perl /tmp/sqlany\n
  \ cd /tmp/sqlany\n  perl Makefile.PL\n  make\n  sudo make install\n  cd\n  rm -rf
  /tmp/sqlany\n\nTest it out:\n\n  lang:bash\n  perl -MDBI -le 'my $dbh = DBI->connect(\"dbi:SQLAnywhere:\",
  \"DBA\", \"SQL\"); print for $dbh->selectrow_array(\"select 42\")'\n\n=head1 Using
  DBI::Shell (dbish)\n\nIf you don't like C<Interactive SQL> or C<sqsh>, you can try
  the Perl module\nDBI::Shell for a commandline SQL utility.\n\nFirst install it:\n\n
  \ lang:bash\n  curl -L http://cpanmin.us | perl - -S App::cpanminus\n  cpanm -n
  -S DBI::Shell\n\nThen launch it. I would recommend using the ODBC driver, especially
  if you use\nUUID columns:\n\n  lang:bash\n  dbish dbi:ODBC:driver=SQLAnywhere DBA
  SQL\n\nTo use the Perl binding:\n\n  lang:bash\n  dbish dbi:SQLAnywhere: DBA SQL\n\nSQL
  statements are terminated by semicolons, type C</quit> to exit the shell and\nC</help>
  to see what commands are available.\n\nIf you would like to save the readline history
  of your sessions and use it for\ncompletion, you can wrap it with C<rlwrap>. To
  do so add this alias to your\nC<~/.bashrc>:\n\n  lang:bash\n  alias sqlany=\"rlwrap
  -a -N -t dumb -i -f ~/.sqlanywhere_dbish_history -H ~/.sqlanywhere_dbish_history
  -s 30000 dbish dbi:ODBC:driver=SQLAnywhere DBA SQL\"\n\nand initialize the history
  file:\n\n  lang:bash\n  touch ~/.sqlanywhere_dbish_history\n\nthen you can type
  C<sqlany> to launch the shell.\n\n=head1 DBIx::Class ORM Support\n\nThere is complete
  support for SQL Anywhere in DBIx::Class and\nDBIx::Class::Schema::Loader (the Catalyst
  create=static helper.)\n\n=head1 That's All\n\nHope you found this guide helpful.
  Feel free to leave comments on the blog or\nemail me if you have questions.\n\n=cut\n-----BEGIN
  PGP SIGNATURE-----\nVersion: GnuPG v1.4.11 (GNU/Linux)\n\niQCVAwUBTn2s6Oz9kGY+SikhAQKuIgP+O0VHv7SOgz1B5oVravIEk/eDLo9Uv2ef\n+QofdWp4LwH/rTGlNrvW1E6ffZQ5CXknOp0I61uB3XRvD2jOwECWlAECsAee9d0p\n9X/+NSR9K12zWMmmJylJq/yB1z1ORshg1JXoJzp+KZfPZjJ7lTAVSF1KpsuvCa9U\nuBYXGKHn3uY=\n=++qb\n-----END
  PGP SIGNATURE-----\n"
signed: 1
summary: ' Here I will go through the steps necessary to …'
tags:
- osx: 0
- databases: 0
- sqlanywhere: 0
- mac: 0
text: "    Here I will go through the steps necessary to set up and use SQL\n    Anywhere
  on Mac OS X.\n\nDownload and Install SQL Anywhere\n\n    It is available here: http://www.sybase.com/detail?id=1016644\n
  \   <http://www.sybase.com/detail?id=1016644>.\n\n    Open the package and double
  click the Install SQL Anywhere icon, se-\n    lect all components.\n\n    At the
  end click the Check for Updates button, it will take you to\n    the EBF download.
  You will need to create a MySybase account to\n    download the EBF package. Download
  the package, doubleclick the In-\n    stall SQL Anywhere icon and select the update
  product option.\n\nSet up Your User Environment\n\n    Add the following to your
  ~/.bashrc:\n\n      lang:bash export SQLANYWHERE_HOME=/Applications/SQLAnywhere12/Sys-\n
  \     tem export\n      DYLD_LIBRARY_PATH=$SQLANYWHERE_HOME/lib64:$SQLANYWHERE_HOME/lib32:\n
  \     $DYLD_LIBRARY_PATH export DYLD_BIND_AT_LAUNCH=1 export\n      PATH=$PATH:$SQLANYWHERE_HOME/bin64:$SQLANYWHERE_HOME/bin32\n\n
  \   For the next step, open a new terminal session for the environment\n    changes
  to take effect.\n\nCreate a Database\n\n    Execute the following to create a new
  database:\n\n      lang:bash cd mkdir sqlanywhere cd sqlanywhere mkdir logs dbinit
  -t\n      ./logs/hlaghdb.log -p 4096 -dba DBA,SQL hlaghdb.db\n\nSet up the Database
  Server\n\n    Create a file called ~/Library/LaunchAgents/com.ianywhere.sqlany-\n
  \   where.plist, put the following in that file, changing /Users/rki-\n    tover
  to your actual home directory and the database file name to\n    your actual database
  file:\n\n      lang:xml <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE plist\n
  \     PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.-\n      com/DTDs/PropertyList-1.0.dtd\"
  > <plist version='1.0'> <dict>\n      <key>Label</key><string>com.ianywhere.sqlanywhere</string>\n
  \     <key>WorkingDirectory</key><string>/Users/rkitover/sqlany-\n      where</string>
  <key>EnvironmentVariables</key> <dict>\n      <key>DYLD_LIBRARY_PATH</key> <string>/Applications/SQLAny-\n
  \     where12/System/lib64:/Applications/SQLAnywhere12/Sys-\n      tem/lib32</string>
  <key>DYLD_BIND_AT_LAUNCH</key>\n      <string>1</string> </dict> <key>ProgramArguments</key>
  <array>\n      <string>/Applications/SQLAnywhere12/System/bin32/dbsrv12</string>\n
  \     <string>-ud</string> <string>/Users/rkitover/sqlanywhere/hlaghd-\n      b.db</string>
  </array> <key>Debug</key><false/> <key>Dis-\n      abled</key><true/> <key>KeepAlive</key><true/>
  </dict> </plist>\n\n    NOTE: we do not give the database server a name in this
  example.\n          This is because for some reason when I tried to use -n option\n
  \         to dbsrv12 it responded with Communication error. Try running\n          dbsrv12
  from the command line with the -n option to see if it\n          works for you,
  if it does add it to the ProgramArguments in\n          the .plist file. E.g.:\n\n
  \     lang:bash dbsrv12 -ud -n SQLANYWHERE hlaghdb.db\n\n    If this works, add
  the following to the .plist file after dbsrv12:\n\n      lang:xml <string>-n</string>
  <string>SQLANYWHERE</string>\n\n    The following examples will all assume the database
  server has no\n    name.\n\n    Now execute the following to load the service and
  start the\n    database server:\n\n      lang:bash launchctl load -w ~/Library/LaunchAgents/com.iany-\n
  \     where.sqlanywhere.plist launchctl start com.ianywhere.sqlanywhere\n\n    You
  should see the database server in ps:\n\n      lang:bash $ ps aux | grep dbsrv rkitover
  51654 0.3 0.2 1627072\n      14000 ?? Ss 1:02PM 0:03.07 /Applications/SQLAnywhere12/Sys-\n
  \     tem/bin32/dbsrv12 -ud /Users/rkitover/sqlanywhere/hlaghdb.db\n\n    It will
  be started across reboots.\n\n    launchctl stop doesn't work with this plist, so
  if you need to\n    restart the server, just kill the process and do a launchctl
  stop\n    followed by a launchctl start.\n\nThe SQL Anywhere Applications\n\n    Open
  the SQLAnywhere12 folder under Applications in Finder.\n\n    The applications we're
  interested in are Sybase Central and Inter-\n    active SQL.\n\n    The Sybase Central
  application will allow you to configure all\n    aspects of your database. To use
  it, open the application, double\n    click on the SQL Anywhere 12 plugin, right
  click inside the blank\n    window and choose Connect, choose Connect to a running
  database on\n    this computer, enter the username and password you used with the
  d-\n    binit command, which in this example is DBA and SQL respectively.\n\n    The
  Interactive SQL application is a handy GUI for testing SQL s-\n    tatements on
  your database. To login, open the application, choose\n    Database authentication,
  choose Connect to a running database on\n    this computer, enter your username
  and password and press Connect.\n    Inside the application, enter your SQL statements
  in the SQL state-\n    ments window and press F5 to execute them; you will see your
  results\n    in the results window.\n\nUsing sqsh\n\n    If you would prefer a commandline
  utility to Interactive SQL for\n    testing SQL statements, you can use the sqsh
  utility from MacPorts\n    (http://www.macports.org/.)\n\n    The sqsh utility is
  an interactive SQL utility for databases using\n    the TDS protocol, such as Sybase
  ASE and Microsoft SQL Server. SQL\n    Anywhere also uses the TDS protocol, so the
  utility works for these\n    databases as well.\n\n    If you do not yet have an
  interfaces file, follow these steps to\n    set one up.\n\n    In your .bashrc add
  the following:\n\n      lang:bash export SYBASE=~/sybase\n\n    In this directory
  create a file called interfaces with the\n    following:\n\n      SQLANYWHERE master
  tcp ether localhost 2638 query tcp ether lo-\n      calhost 2638\n\n    Now you
  can launch sqsh like so:\n\n      lang:bash sqsh -S SQLANYWHERE -U DBA -P SQL\n\n
  \   To use it, type in a SQL statement, it can span multiple lines, then\n    type
  go on a line by itself to execute it. This may take some get-\n    ting used to
  if you're used to tools such as sqlplus or dbish, where\n    SQL statements are
  terminated by a semicolon. You can use dbish with\n    SQL Anywhere as well, I will
  describe how to do so further down.\n\nSetting up ODBC\n\n    If you have UnixODBC
  from MacPorts (http://www.macports.org/,) you\n    can set up the included ODBC
  drivers with it.\n\n    In /opt/local/etc/odbcinst.ini add the following:\n\n      lang:ini
  [SQLAnywhere] Description = SQL Anywhere Driver = /Ap-\n      plications/SQLAnywhere12/System/lib64/libdbodbc12.dylib
  Setup =\n      /Applications/SQLAnywhere12/System/lib64/libdbodbc12.dylib\n      FileUsage
  = 1\n\n    Now lets test it out (take out the -S flag to cpanm if you use lo-\n
  \   cal::lib):\n\n      lang:bash curl -L http://cpanmin.us | perl - -S App::cpanminus
  c-\n      panm -n -S DBI cpanm -n -S DBD::ODBC perl -MDBI -le 'my $dbh =\n      DBI->connect(\"dbi:ODBC:driver=SQLAnywhere\",
  \"DBA\", \"SQL\"); print\n      for $dbh->selectrow_array(\"select 42\")'\n\nInstalling
  the Perl Driver\n\n    First install DBI:\n\n      lang:bash curl -L http://cpanmin.us
  | perl - -S App::cpanminus c-\n      panm -n -S DBI\n\n    Then build and install
  the Perl library:\n\n      lang:bash cp -a /Applications/SQLAnywhere12/sdk/perl
  /tmp/sqlany\n      cd /tmp/sqlany perl Makefile.PL make sudo make install cd rm
  -rf\n          /tmp/sqlany\n\n    Test it out:\n\n      lang:bash perl -MDBI -le
  'my $dbh = DBI->connect(\"dbi:SQLAny-\n      where:\", \"DBA\", \"SQL\"); print
  for $dbh->selectrow_array(\"se-\n      lect 42\")'\n\nUsing DBI::Shell (dbish)\n\n
  \   If you don't like Interactive SQL or sqsh, you can try the Perl mod-\n    ule
  DBI::Shell for a commandline SQL utility.\n\n    First install it:\n\n      lang:bash
  curl -L http://cpanmin.us | perl - -S App::cpanminus c-\n      panm -n -S DBI::Shell\n\n
  \   Then launch it. I would recommend using the ODBC driver, especially\n    if
  you use UUID columns:\n\n      lang:bash dbish dbi:ODBC:driver=SQLAnywhere DBA SQL\n\n
  \   To use the Perl binding:\n\n      lang:bash dbish dbi:SQLAnywhere: DBA SQL\n\n
  \   SQL statements are terminated by semicolons, type /quit to exit the\n    shell
  and /help to see what commands are available.\n\n    If you would like to save the
  readline history of your sessions and\n    use it for completion, you can wrap it
  with rlwrap. To do so add\n    this alias to your ~/.bashrc:\n\n      lang:bash
  alias sqlany=\"rlwrap -a -N -t dumb -i -f ~/.sqlany-\n      where_dbish_history
  -H ~/.sqlanywhere_dbish_history -s 30000 dbish\n      dbi:ODBC:driver=SQLAnywhere
  DBA SQL\"\n\n    and initialize the history file:\n\n      lang:bash touch ~/.sqlanywhere_dbish_history\n\n
  \   then you can type sqlany to launch the shell.\n\nDBIx::Class ORM Support\n\n
  \   There is complete support for SQL Anywhere in DBIx::Class and\n    DBIx::Class::Schema::Loader
  (the Catalyst create=static helper.)\n\nThat's All\n\n    Hope you found this guide
  helpful. Feel free to leave comments on\n    the blog or email me if you have questions.\n"
title: Using SQL Anywhere on Mac OS X
type: pod
uri: http://blog.cachemiss.com/articles/Using%20SQL%20Anywhere%20on%20Mac%20OS%20X.pod
xhtml: "<div class=\"pod\">\n<p>Here I will go through the steps necessary to set
  up and use SQL Anywhere on Mac\nOS X.</p>\n<h3 id=\"Download_and_Install_SQL_Anywhere\">Download
  and Install SQL Anywhere</h3>\n<div id=\"Download_and_Install_SQL_Anywhere_CO\">\n<p>It
  is available here: <a href=\"http://www.sybase.com/detail?id=1016644\">http://www.sybase.com/detail?id=1016644</a>.</p>\n<p>Open
  the package and double click the <code>Install SQL Anywhere</code> icon, select
  all\ncomponents.</p>\n<p>At the end click the <code>Check for Updates</code> button,
  it will take you to the EBF\ndownload. You will need to create a MySybase account
  to download the EBF\npackage. Download the package, doubleclick the <code>Install
  SQL Anywhere</code> icon and\nselect the <code>update product</code> option.</p>\n\n</div>\n<h3
  id=\"Set_up_Your_User_Environment\">Set up Your User Environment</h3>\n<div id=\"Set_up_Your_User_Environment_CONTENT\">\n<p>Add
  the following to your <code>~/.bashrc</code>:</p>\n<pre><span class=\"Reserved\">export</span><span
  class=\"Normal\"> </span><span class=\"Others\">SQLANYWHERE_HOME=</span><span class=\"Normal\">/Applications/SQLAnywhere12/System</span><span
  class=\"Normal\">\n</span><span class=\"Others\">export</span><span class=\"Normal\">
  </span><span class=\"Others\">DYLD_LIBRARY_PATH=$SQLANYWHERE_HOME</span><span class=\"Normal\">/lib64:</span><span
  class=\"Others\">$SQLANYWHERE_HOME</span><span class=\"Normal\">/lib32:</span><span
  class=\"Others\">$DYLD_LIBRARY_PATH</span><span class=\"Normal\">\n</span><span
  class=\"Others\">export</span><span class=\"Normal\"> </span><span class=\"Others\">DYLD_BIND_AT_LAUNCH=</span><span
  class=\"Normal\">1</span><span class=\"Normal\">\n</span><span class=\"Others\">export</span><span
  class=\"Normal\"> </span><span class=\"Others\">PATH=$PATH</span><span class=\"Normal\">:</span><span
  class=\"Others\">$SQLANYWHERE_HOME</span><span class=\"Normal\">/bin64:</span><span
  class=\"Others\">$SQLANYWHERE_HOME</span><span class=\"Normal\">/bin32</span>\n</pre>\n<p>For
  the next step, open a new terminal session for the environment changes to\ntake
  effect.</p>\n\n</div>\n<h3 id=\"Create_a_Database\">Create a Database</h3>\n<div
  id=\"Create_a_Database_CONTENT\">\n<p>Execute the following to create a new database:</p>\n<pre><span
  class=\"Reserved\">cd</span><span class=\"Normal\">\n</span><span class=\"BString\">mkdir</span><span
  class=\"Normal\"> sqlanywhere</span><span class=\"Normal\">\n</span><span class=\"Reserved\">cd</span><span
  class=\"Normal\"> sqlanywhere</span><span class=\"Normal\">\n</span><span class=\"BString\">mkdir</span><span
  class=\"Normal\"> logs</span><span class=\"Normal\">\n</span><span class=\"Normal\">dbinit
  -t ./logs/hlaghdb.log -p 4096 -dba DBA,SQL hlaghdb.db</span>\n</pre>\n\n</div>\n<h3
  id=\"Set_up_the_Database_Server\">Set up the Database Server</h3>\n<div id=\"Set_up_the_Database_Server_CONTENT\">\n<p>Create
  a file called <code>~/Library/LaunchAgents/com.ianywhere.sqlanywhere.plist</code>,\nput
  the following in that file, changing <code>/Users/rkitover</code> to your actual
  home\ndirectory and the database file name to your actual database file:</p>\n<pre>&lt;?xml
  version='1.0' encoding='UTF-8'?&gt;\n&lt;!DOCTYPE plist PUBLIC &quot;-//Apple Computer//DTD
  PLIST 1.0//EN&quot;\n&quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;
  &gt;\n&lt;plist version='1.0'&gt;\n&lt;dict&gt;\n&lt;key&gt;Label&lt;/key&gt;&lt;string&gt;com.ianywhere.sqlanywhere&lt;/string&gt;\n&lt;key&gt;WorkingDirectory&lt;/key&gt;&lt;string&gt;/Users/rkitover/sqlanywhere&lt;/string&gt;\n&lt;key&gt;EnvironmentVariables&lt;/key&gt;\n
  \   &lt;dict&gt;\n        &lt;key&gt;DYLD_LIBRARY_PATH&lt;/key&gt;\n        &lt;string&gt;/Applications/SQLAnywhere12/System/lib64:/Applications/SQLAnywhere12/System/lib32&lt;/string&gt;\n
  \       &lt;key&gt;DYLD_BIND_AT_LAUNCH&lt;/key&gt;\n        &lt;string&gt;1&lt;/string&gt;\n
  \   &lt;/dict&gt;\n&lt;key&gt;ProgramArguments&lt;/key&gt;\n&lt;array&gt;\n        &lt;string&gt;/Applications/SQLAnywhere12/System/bin32/dbsrv12&lt;/string&gt;\n
  \       &lt;string&gt;-ud&lt;/string&gt;\n        &lt;string&gt;/Users/rkitover/sqlanywhere/hlaghdb.db&lt;/string&gt;\n&lt;/array&gt;\n&lt;key&gt;Debug&lt;/key&gt;&lt;false/&gt;\n&lt;key&gt;Disabled&lt;/key&gt;&lt;true/&gt;\n&lt;key&gt;KeepAlive&lt;/key&gt;&lt;true/&gt;\n&lt;/dict&gt;\n&lt;/plist&gt;\n</pre>\n<p><strong>NOTE:</strong>
  we do not give the database server a name in this example. This is\nbecause for
  some reason when I tried to use <code>-n</code> option to <code>dbsrv12</code> it\nresponded
  with <code>Communication error</code>. Try running <code>dbsrv12</code> from the
  command\nline with the <code>-n</code> option to see if it works for you, if it
  does add it to the\n<code>ProgramArguments</code> in the <code>.plist</code> file.
  E.g.:</p>\n<pre><span class=\"Normal\">dbsrv12 -ud -n SQLANYWHERE hlaghdb.db</span>\n</pre>\n<p>If
  this works, add the following to the <code>.plist</code> file after <code>dbsrv12</code>:</p>\n<pre>&lt;string&gt;-n&lt;/string&gt;\n&lt;string&gt;SQLANYWHERE&lt;/string&gt;\n</pre>\n<p>The
  following examples will all assume the database server has no name.</p>\n<p>Now
  execute the following to load the service and start the database server:</p>\n<pre><span
  class=\"Normal\">launchctl load -w ~/Library/LaunchAgents/com.ianywhere.sqlanywhere.plist</span><span
  class=\"Normal\">\n</span><span class=\"Normal\">launchctl start com.ianywhere.sqlanywhere</span>\n</pre>\n<p>You
  should see the database server in ps:</p>\n<pre><span class=\"Normal\">$ </span><span
  class=\"BString\">ps</span><span class=\"Normal\"> aux </span><span class=\"Keyword\">|</span><span
  class=\"Normal\"> </span><span class=\"BString\">grep</span><span class=\"Normal\">
  dbsrv</span><span class=\"Normal\">\n</span><span class=\"Normal\">rkitover       51654
  \  0.3  0.2  1627072  14000   ??  Ss    1:02PM   0:03.07 /Applications/SQLAnywhere12/System/bin32/dbsrv12
  -ud /Users/rkitover/sqlanywhere/hlaghdb.db</span>\n</pre>\n<p>It will be started
  across reboots.</p>\n<p><code>launchctl stop</code> doesn't work with this plist,
  so if you need to restart the\nserver, just kill the process and do a <code>launchctl
  stop</code> followed by a\n<code>launchctl start</code>.</p>\n\n</div>\n<h3 id=\"The_SQL_Anywhere_Applications\">The
  SQL Anywhere Applications</h3>\n<div id=\"The_SQL_Anywhere_Applications_CONTEN\">\n<p>Open
  the <code>SQLAnywhere12</code> folder under <code>Applications</code> in Finder.</p>\n<p>The
  applications we're interested in are <code>Sybase Central</code> and <code>Interactive\nSQL</code>.</p>\n<p>The
  <code>Sybase Central</code> application will allow you to configure all aspects
  of\nyour database. To use it, open the application, double click on the <code>SQL\nAnywhere
  12</code> plugin, right click inside the blank window and choose <code>Connect</code>,\nchoose
  <code>Connect to a running database on this computer</code>, enter the username
  and\npassword you used with the <code>dbinit</code> command, which in this example
  is <code>DBA</code>\nand <code>SQL</code> respectively.</p>\n<p>The <code>Interactive
  SQL</code> application is a handy GUI for testing SQL statements on\nyour database.
  To login, open the application, choose <code>Database</code>\nauthentication, choose
  <code>Connect to a running database on this computer</code>, enter\nyour username
  and password and press <code>Connect</code>. Inside the application, enter\nyour
  SQL statements in the SQL statements window and press <code>F5</code> to execute\nthem;
  you will see your results in the results window.</p>\n\n</div>\n<h3 id=\"Using_sqsh\">Using
  sqsh</h3>\n<div id=\"Using_sqsh_CONTENT\">\n<p>If you would prefer a commandline
  utility to <code>Interactive SQL</code> for testing SQL\nstatements, you can use
  the sqsh utility from MacPorts\n(<a href=\"http://www.macports.org/\">http://www.macports.org/</a>.)</p>\n<p>The
  <code>sqsh</code> utility is an interactive SQL utility for databases using the
  TDS\nprotocol, such as Sybase ASE and Microsoft SQL Server. SQL Anywhere also uses\nthe
  TDS protocol, so the utility works for these databases as well.</p>\n<p>If you do
  not yet have an <code>interfaces</code> file, follow these steps to set one up.</p>\n<p>In
  your <code>.bashrc</code> add the following:</p>\n<pre><span class=\"Reserved\">export</span><span
  class=\"Normal\"> </span><span class=\"Others\">SYBASE=</span><span class=\"Normal\">~/sybase</span>\n</pre>\n<p>In
  this directory create a file called <code>interfaces</code> with the following:</p>\n<pre><span
  class=\"Normal\">SQLANYWHERE</span><span class=\"Normal\">\n</span><span class=\"Normal\">
  \ master tcp ether localhost 2638</span><span class=\"Normal\">\n</span><span class=\"Normal\">
  \ query tcp ether localhost 2638</span>\n</pre>\n<p>Now you can launch <code>sqsh</code>
  like so:</p>\n<pre><span class=\"Normal\">sqsh -S SQLANYWHERE -U DBA -P SQL</span>\n</pre>\n<p>To
  use it, type in a SQL statement, it can span multiple lines, then type <code>go</code>\non
  a line by itself to execute it. This may take some getting used to if you're\nused
  to tools such as sqlplus or dbish, where SQL statements are terminated by a\nsemicolon.
  You can use dbish with SQL Anywhere as well, I will describe how to\ndo so further
  down.</p>\n\n</div>\n<h3 id=\"Setting_up_ODBC\">Setting up ODBC</h3>\n<div id=\"Setting_up_ODBC_CONTENT\">\n<p>If
  you have UnixODBC from MacPorts (<a href=\"http://www.macports.org/\">http://www.macports.org/</a>,)
  you can set up\nthe included ODBC drivers with it.</p>\n<p>In <code>/opt/local/etc/odbcinst.ini</code>
  add the following:</p>\n<pre>[SQLAnywhere]\nDescription = SQL Anywhere\nDriver =
  /Applications/SQLAnywhere12/System/lib64/libdbodbc12.dylib\nSetup = /Applications/SQLAnywhere12/System/lib64/libdbodbc12.dylib\nFileUsage
  = 1\n</pre>\n<p>Now lets test it out (take out the -S flag to cpanm if you use local::lib):</p>\n<pre><span
  class=\"Normal\">curl -L http://cpanmin.us </span><span class=\"Keyword\">|</span><span
  class=\"Normal\"> </span><span class=\"BString\">perl</span><span class=\"Normal\">
  - -S App::cpanminus</span><span class=\"Normal\">\n</span><span class=\"Normal\">cpanm
  -n -S DBI</span><span class=\"Normal\">\n</span><span class=\"Normal\">cpanm -n
  -S DBD::ODBC</span><span class=\"Normal\">\n</span><span class=\"BString\">perl</span><span
  class=\"Normal\"> -MDBI -le </span><span class=\"String\">&apos;my $dbh = DBI-&gt;connect(&quot;dbi:ODBC:driver=SQLAnywhere&quot;,
  &quot;DBA&quot;, &quot;SQL&quot;); print for $dbh-&gt;selectrow_array(&quot;select
  42&quot;)&apos;</span>\n</pre>\n\n</div>\n<h3 id=\"Installing_the_Perl_Driver\">Installing
  the Perl Driver</h3>\n<div id=\"Installing_the_Perl_Driver_CONTENT\">\n<p>First
  install DBI:</p>\n<pre><span class=\"Normal\">curl -L http://cpanmin.us </span><span
  class=\"Keyword\">|</span><span class=\"Normal\"> </span><span class=\"BString\">perl</span><span
  class=\"Normal\"> - -S App::cpanminus</span><span class=\"Normal\">\n</span><span
  class=\"Normal\">cpanm -n -S DBI</span>\n</pre>\n<p>Then build and install the Perl
  library:</p>\n<pre><span class=\"BString\">cp</span><span class=\"Normal\"> -a /Applications/SQLAnywhere12/sdk/perl
  /tmp/sqlany</span><span class=\"Normal\">\n</span><span class=\"Reserved\">cd</span><span
  class=\"Normal\"> /tmp/sqlany</span><span class=\"Normal\">\n</span><span class=\"BString\">perl</span><span
  class=\"Normal\"> Makefile.PL</span><span class=\"Normal\">\n</span><span class=\"BString\">make</span><span
  class=\"Normal\">\n</span><span class=\"BString\">sudo</span><span class=\"Normal\">
  </span><span class=\"BString\">make</span><span class=\"Normal\"> </span><span class=\"BString\">install</span><span
  class=\"Normal\">\n</span><span class=\"Reserved\">cd</span><span class=\"Normal\">\n</span><span
  class=\"BString\">rm</span><span class=\"Normal\"> -rf /tmp/sqlany</span>\n</pre>\n<p>Test
  it out:</p>\n<pre><span class=\"BString\">perl</span><span class=\"Normal\"> -MDBI
  -le </span><span class=\"String\">&apos;my $dbh = DBI-&gt;connect(&quot;dbi:SQLAnywhere:&quot;,
  &quot;DBA&quot;, &quot;SQL&quot;); print for $dbh-&gt;selectrow_array(&quot;select
  42&quot;)&apos;</span>\n</pre>\n\n</div>\n<h3 id=\"Using_DBI_Shell_dbish\">Using
  DBI::Shell (dbish)</h3>\n<div id=\"Using_DBI_Shell_dbish_CONTENT\">\n<p>If you don't
  like <code>Interactive SQL</code> or <code>sqsh</code>, you can try the Perl module\nDBI::Shell
  for a commandline SQL utility.</p>\n<p>First install it:</p>\n<pre><span class=\"Normal\">curl
  -L http://cpanmin.us </span><span class=\"Keyword\">|</span><span class=\"Normal\">
  </span><span class=\"BString\">perl</span><span class=\"Normal\"> - -S App::cpanminus</span><span
  class=\"Normal\">\n</span><span class=\"Normal\">cpanm -n -S DBI::Shell</span>\n</pre>\n<p>Then
  launch it. I would recommend using the ODBC driver, especially if you use\nUUID
  columns:</p>\n<pre><span class=\"Normal\">dbish dbi:ODBC:</span><span class=\"Others\">driver=</span><span
  class=\"Normal\">SQLAnywhere DBA SQL</span>\n</pre>\n<p>To use the Perl binding:</p>\n<pre><span
  class=\"Normal\">dbish dbi:SQLAnywhere: DBA SQL</span>\n</pre>\n<p>SQL statements
  are terminated by semicolons, type <code>/quit</code> to exit the shell and\n<code>/help</code>
  to see what commands are available.</p>\n<p>If you would like to save the readline
  history of your sessions and use it for\ncompletion, you can wrap it with <code>rlwrap</code>.
  To do so add this alias to your\n<code>~/.bashrc</code>:</p>\n<pre><span class=\"Reserved\">alias</span><span
  class=\"Normal\"> </span><span class=\"Others\">sqlany=</span><span class=\"String\">&quot;rlwrap
  -a -N -t dumb -i -f ~/.sqlanywhere_dbish_history -H ~/.sqlanywhere_dbish_history
  -s 30000 dbish dbi:ODBC:driver=SQLAnywhere DBA SQL&quot;</span>\n</pre>\n<p>and
  initialize the history file:</p>\n<pre><span class=\"BString\">touch</span><span
  class=\"Normal\"> ~/.sqlanywhere_dbish_history</span>\n</pre>\n<p>then you can type
  <code>sqlany</code> to launch the shell.</p>\n\n</div>\n<h3 id=\"DBIx_Class_ORM_Support\">DBIx::Class
  ORM Support</h3>\n<div id=\"DBIx_Class_ORM_Support_CONTENT\">\n<p>There is complete
  support for SQL Anywhere in DBIx::Class and\nDBIx::Class::Schema::Loader (the Catalyst
  create=static helper.)</p>\n\n</div>\n<h3 id=\"That_s_All\">That's All</h3>\n<div
  id=\"That_s_All_CONTENT\">\n<p>Hope you found this guide helpful. Feel free to leave
  comments on the blog or\nemail me if you have questions.</p>\n\n</div>\n</div>"
---
author:
  email: rkitover@io.com
  keyid: ecfd90663e4a2921
  name: Rafael Kitover
categories: []
date: 2011-02-05T04:08:25Z
guid: 9F02EA74-30DD-11E0-8E48-75D120E7A903
modified: 2011-02-05T04:08:25Z
raw: "-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\n=pod\n\nBy default, Oracle's
  SQL*Plus has no support for history, command line editing,\netc.\n\nThis problem
  can be solved with the C<rlwrap> utility. There is a Debian\npackage, or you can
  easily compile it for any system.\n\nSource is here: L<http://utopia.knoware.nl/~hlub/rlwrap/>.\n\nOnce
  installed, add this alias to your C<.bashrc>:\n\n  lang:bash\n  alias sqlplus=\"rlwrap
  -i -f ~/.sqlplus_history -H ~/.sqlplus_history -s 30000 sqlplus\"\n\nThis defines
  a history file and uses it as your completion wordlist, and sets\nthe history size
  to 30000 entries.\n\nBefore running it for the first time, do a:\n\n  lang:bash\n
  \ touch ~/.sqlplus_history\n\nThat's all there is to it, and now you have readline
  support in your SQL*Plus!\n\nAlso check out another Oracle utility called yasql.
  You can find more\ninformation on it here: L<http://www.orafaq.com/wiki/YaSQL>.\n\n=cut\n-----BEGIN
  PGP SIGNATURE-----\nVersion: GnuPG v1.4.10 (GNU/Linux)\n\niQCVAwUBTUzNNuz9kGY+SikhAQJkMgP8DKjSbVmW2gJlnmaBdR2CAEuonxoj4+7n\nmopYJCopz5EqpwfKWtpAkJjqEl5Ro1F19/fHdpZfE4LIhFJNlko8LDsUGMfS49/U\nGxPFpJ5knUR0Q6r0TGxvxIqjWc6MRy2uvV5gXyaj4eabGn8jVJ3G2JnLbbyc3K61\n5dsuBOgeF/U=\n=umgu\n-----END
  PGP SIGNATURE-----\n"
signed: 1
summary: ' By default, Oracle''s SQL*Plus has no support for history, …'
tags:
- sqlplus: 0
- readline: 0
- oracle: 0
- yasql: 0
text: "    By default, Oracle's SQL*Plus has no support for history, command\n    line
  editing, etc.\n\n    This problem can be solved with the rlwrap utility. There is
  a De-\n    bian package, or you can easily compile it for any system.\n\n    Source
  is here: http://utopia.knoware.nl/~hlub/rlwrap/.\n\n    Once installed, add this
  alias to your .bashrc:\n\n      lang:bash alias sqlplus=\"rlwrap -i -f ~/.sqlplus_history
  -H\n      ~/.sqlplus_history -s 30000 sqlplus\"\n\n    This defines a history file
  and uses it as your completion wordlist,\n    and sets the history size to 30000
  entries.\n\n    Before running it for the first time, do a:\n\n      lang:bash touch
  ~/.sqlplus_history\n\n    That's all there is to it, and now you have readline support
  in y-\n    our SQL*Plus!\n\n    Also check out another Oracle utility called yasql.
  You can find\n    more information on it here: http://www.orafaq.com/wiki/YaSQL.\n"
title: Using readline with Oracle SQL*Plus
type: pod
uri: http://blog.cachemiss.com/articles/Using%20readline%20with%20Oracle%20SQL%2APlus.pod
xhtml: '<div class="pod">

  <p>By default, Oracle''s SQL*Plus has no support for history, command line editing,

  etc.</p>

  <p>This problem can be solved with the <code>rlwrap</code> utility. There is a Debian

  package, or you can easily compile it for any system.</p>

  <p>Source is here: <a href="http://utopia.knoware.nl/~hlub/rlwrap/">http://utopia.knoware.nl/~hlub/rlwrap/</a>.</p>

  <p>Once installed, add this alias to your <code>.bashrc</code>:</p>

  <pre><span class="Reserved">alias</span><span class="Normal"> </span><span class="Others">sqlplus=</span><span
  class="String">&quot;rlwrap -i -f ~/.sqlplus_history -H ~/.sqlplus_history -s 30000
  sqlplus&quot;</span>

  </pre>

  <p>This defines a history file and uses it as your completion wordlist, and sets

  the history size to 30000 entries.</p>

  <p>Before running it for the first time, do a:</p>

  <pre><span class="BString">touch</span><span class="Normal"> ~/.sqlplus_history</span>

  </pre>

  <p>That''s all there is to it, and now you have readline support in your SQL*Plus!</p>

  <p>Also check out another Oracle utility called yasql. You can find more

  information on it here: <a href="http://www.orafaq.com/wiki/YaSQL">http://www.orafaq.com/wiki/YaSQL</a>.</p>



  </div>'
---
author:
  email: rkitover@io.com
  keyid: ecfd90663e4a2921
  name: Rafael Kitover
categories: []
date: 2011-02-01T04:18:59Z
guid: 8F3BF42A-2DC0-11E0-ADEF-78D120E7A903
modified: 2011-02-01T06:10:12Z
raw: "-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\n=pod\n\nI wanted to set up
  a cmd.exe environment similar to my msys .bashrc for msysGit\n(L<http://code.google.com/p/msysgit/>),
  to set up environment variables and\ndoskey macros (aliases.)\n\nThis post will
  show you some techniques for doing this.\n\nAs Larry Wall said, \"it's easier to
  port a shell than a shell script.\"\n\nI use Console2 for my various command prompts
  (msysgit, powershell, cmd.exe...)\nyou can get it here: L<https://sourceforge.net/projects/console/>.\n\nFirst,
  how do we tell cmd.exe to run a script on startup? There are two ways,\nthe way
  I use is with the /K option to run a batch file and continue. Another\noption is
  to set a registry key, see C<cmd /?> for what registry key to set.\n\nMake a file
  called .cmd_profile.cmd in your %HOME%, then configure your cmd.exe\ntabs in Console2
  to something like this:\n\n  c:\\windows\\system32\\cmd.exe /K c:\\Users\\rkitover\\.cmd_profile.cmd\n\nOr
  make a shortcut on your desktop with this command line.\n\nOr set that registry
  to the location of your profile script.\n\nMy .cmd_profile.cmd looks like this:\n\n
  \ @echo off\n\n  REM Presumably we will only use real consoles with this profile.\n
  \ REM And perl readline only works with TERM=dumb .\n  REM Set this to 'cygwin'
  to work with cygwin utilities.\n  set TERM=dumb\n\n  doskey use_strawberry64=^\n
  \     set PATH=c:\\strawberry\\perl\\site\\bin;c:\\strawberry\\perl\\bin;c:\\strawberry\\c\\bin;%PATH%^\n
  \     $Tcall remove_path_dups^\n      $Tcall strawberry_maint_macros\n\n  doskey
  use_activeperl64=^\n      set PATH=C:\\Perl64\\site\\bin;C:\\Perl64\\bin;C:\\Program
  Files (x86)\\Microsoft Visual Studio 10.0\\VC\\bin\\amd64;%PATH%^\n      $Tcall
  remove_path_dups^\n      $Tset LIB=C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib\\x64;C:\\Program
  Files (x86)\\Microsoft Visual Studio 10.0\\VC\\lib\\amd64^\n      $Tcall activestate_maint_macros\n\n
  \ doskey use_activeperl32=^\n      set PATH=C:\\Perl\\site\\bin;C:\\Perl\\bin;c:\\Program
  Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE;c:\\Program Files (x86)\\Microsoft
  Visual Studio 10.0\\VC\\bin;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Tools;c:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;c:\\Windows\\Microsoft.NET\\Framework\\v3.5;c:\\Program
  Files (x86)\\Microsoft Visual Studio 10.0\\VC\\VCPackages;c:\\Program Files (x86)\\Microsoft
  SDKs\\Windows\\v7.0A\\bin\\NETFX 4.0 Tools;c:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin;%PATH%^\n
  \     $Tcall remove_path_dups^\n      $Tset LIB=C:\\Program Files (x86)\\Microsoft
  Visual Studio 10.0\\VC\\lib;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\lib^\n
  \     $Tset LIBPATH=c:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;C:\\Program
  Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB^\n      $Tcall activestate_maint_macros\n\n
  \ call exec_macro use_activeperl32\n\nSome features to notice here:\n\n=over 4\n\n=item
  line continuation\n\nThe line continuation and escape character for certain shell
  metacharacters in\nbatch files is C<^>.\n\n=item doskey command separator\n\nThe
  command separator in doskey macros is C<$T>, see C<doskey /?> for more\ninformation.\n\n=item
  environment variable expansion\n\nEnvironment variables are expanded immediately
  when the batch file is executed,\nnot when the command using them runs. Here the
  %PATH% I use is the %PATH% my\ncmd.exe starts with, always. This is not what happens
  in my .bashrc, but it\nsuits my purposes in this case well enough that I haven't
  fixed it yet.\n\n=back\n\nThere are a couple of supporting .cmd utilities to go
  along with this profile. I\nput them into C:\\Users\\rkitover\\bin and put that
  directory in my %PATH%.\n\n=over 4\n\n=item exec_macro.cmd\n\n  @echo off\n\n  for
  /f \"usebackq tokens=*\" %%x in (`doskey /macros ^| perl -ne \"next unless s/^%*=//;
  s/\\s*\\$T/\\n/g; print\"`) do %%x\n\n=item remove_path_dups.cmd\n\n  @echo off\n\n
  \ for /f \"usebackq tokens=*\" %%x in (`perl -le \"for (split /;/, $ENV{PATH}) {
  $p{$_} || do { $p{$_}++; push @p, $_ }; } print join q{;}, @p\"`) do set PATH=%%x\n\n=item
  strawberry_maint_macros.cmd\n\n  @echo off\n\n  doskey pclean=perl Makefile.PL$Tdmake
  realclean$Tdel /F MANIFEST\n\n  doskey pinst=perl Makefile.PL$Tdmake$Tdmake install$Tcall
  exec_macro pclean\n\n  doskey pprepare=rmdir /S inc $Tdel /F MANIFEST$Tperl Makefile.PL$Tdmake
  manifest$Tperl Makefile.PL$Tdmake\n\n  doskey pdist=call exec_macro pprepare$Tdmake
  dist\n\n  doskey pupload=call exec_macro pprepare$Tdmake upload\n\n=item activeperl_maint_macros.cmd\n\n
  \ @echo off\n\n  doskey pclean=perl Makefile.PL$Tnmake realclean$Tdel /F MANIFEST\n\n
  \ doskey pinst=perl Makefile.PL$Tnmake$Tnmake install$Tcall exec_macro pclean\n\n
  \ doskey pprepare=rmdir /S inc $Tdel /F MANIFEST$Tperl Makefile.PL$Tnmake manifest$Tperl
  Makefile.PL$Tnmake\n\n  doskey pdist=call exec_macro pprepare$Tnmake dist\n\n  doskey
  pupload=call exec_macro pprepare$Tnmake upload\n\n=back\n\nThese use perl, I'll
  fix them to use something native like powershell or wsh at\nsome point, but I don't
  know those languages yet.\n\n=cut\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG
  v1.4.10 (GNU/Linux)\n\niQCVAwUBTUejwez9kGY+SikhAQL0fgQArYXiCebwso2/v/xbhieQ4aekd0o0hlbH\naKBBp4HP/esM4MZMjKmdMSjVkB2hYqPmdf5S8VtKPxZyhUv4np6AuEYRJhGrLPNI\nfxfNfDMRB8opOATRsFPAyjr9iALJyf7MPIw6QCi5TAdB6dxW++MqQJbkPbXNwPli\n9DYz79hJV8c=\n=cC26\n-----END
  PGP SIGNATURE-----\n"
signed: 1
summary: ' I wanted to set up a cmd.exe environment similar …'
tags:
- profile: 0
- batch-programming: 0
- batch-files: 0
- cmd.exe: 0
- batch: 0
- cmd: 0
- windows: 0
- bashrc: 0
text: "    I wanted to set up a cmd.exe environment similar to my msys .bashrc\n    for
  msysGit (http://code.google.com/p/msysgit/), to set up environ-\n    ment variables
  and doskey macros (aliases.)\n\n    This post will show you some techniques for
  doing this.\n\n    As Larry Wall said, \"it's easier to port a shell than a shell
  scrip-\n    t.\"\n\n    I use Console2 for my various command prompts (msysgit,
  powershel-\n    l, cmd.exe...) you can get it here: https://sourceforge.net/pro-\n
  \   jects/console/.\n\n    First, how do we tell cmd.exe to run a script on startup?
  There are\n    two ways, the way I use is with the /K option to run a batch file\n
  \   and continue. Another option is to set a registry key, see cmd /?\n    for what
  registry key to set.\n\n    Make a file called .cmd_profile.cmd in your %HOME%,
  then configure\n    your cmd.exe tabs in Console2 to something like this:\n\n      c:\\windows\\system32\\cmd.exe
  /K c:\\Users\\rkitover\\.cmd_profile.cmd\n\n    Or make a shortcut on your desktop
  with this command line.\n\n    Or set that registry to the location of your profile
  script.\n\n    My .cmd_profile.cmd looks like this:\n\n      @echo off\n\n      REM
  Presumably we will only use real consoles with this profile.\n      REM And perl
  readline only works with TERM=dumb . REM Set this to\n      'cygwin' to work with
  cygwin utilities. set TERM=dumb\n\n      doskey use_strawberry64=^ set PATH=c:\\strawberry\\per-\n
  \     l\\site\\bin;c:\\strawberry\\perl\\bin;c:\\strawberry\\c\\bin;%PATH%^ $T-\n
  \     call remove_path_dups^ $Tcall strawberry_maint_macros\n\n      doskey use_activeperl64=^
  set PATH=C:\\Perl64\\site\\bin;C:\\Per-\n      l64\\bin;C:\\Program Files (x86)\\Microsoft
  Visual Studio\n      10.0\\VC\\bin\\amd64;%PATH%^ $Tcall remove_path_dups^ $Tset\n
  \     LIB=C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib\\x64;C:\\Pro-\n
  \     gram Files (x86)\\Microsoft Visual Studio 10.0\\VC\\lib\\amd64^ $Tcall\n      activestate_maint_macros\n\n
  \     doskey use_activeperl32=^ set PATH=C:\\Perl\\site\\bin;C:\\Per-\n      l\\bin;c:\\Program
  Files (x86)\\Microsoft Visual Studio 10.0\\Com-\n      mon7\\IDE;c:\\Program Files
  (x86)\\Microsoft Visual Studio\n      10.0\\VC\\bin;c:\\Program Files (x86)\\Microsoft
  Visual Studio\n      10.0\\Common7\\Tools;c:\\Windows\\Microsoft.NET\\Frame-\n      work\\v4.0.30319;c:\\Windows\\Microsoft.NET\\Framework\\v3.5;c:\\Program\n
  \     Files (x86)\\Microsoft Visual Studio 10.0\\VC\\VCPackages;c:\\Program\n      Files
  (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin\\NETFX 4.0 Tool-\n      s;c:\\Program
  Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin;%PATH%^\n      $Tcall remove_path_dups^
  $Tset LIB=C:\\Program Files (x86)\\Mi-\n      crosoft Visual Studio 10.0\\VC\\lib;C:\\Program
  Files (x86)\\Microsoft\n      SDKs\\Windows\\v7.0A\\lib^ $Tset LIBPATH=c:\\Windows\\Microsoft-\n
  \     .NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Frame-\n      work\\v3.5;C:\\Program
  Files (x86)\\Microsoft Visual Studio\n      10.0\\VC\\LIB^ $Tcall activestate_maint_macros\n\n
  \     call exec_macro use_activeperl32\n\n    Some features to notice here:\n\n
  \   line continuation\n\n      The line continuation and escape character for certain
  shell\n      metacharacters in batch files is ^.\n\n    doskey command separator\n\n
  \     The command separator in doskey macros is $T, see doskey /? for\n      more
  information.\n\n    environment variable expansion\n\n      Environment variables
  are expanded immediately when the batch file\n      is executed, not when the command
  using them runs. Here the %PATH%\n      I use is the %PATH% my cmd.exe starts with,
  always. This is not\n      what happens in my .bashrc, but it suits my purposes
  in this case\n      well enough that I haven't fixed it yet.\n\n    There are a
  couple of supporting .cmd utilities to go along with\n    this profile. I put them
  into C:\\Users\\rkitover\\bin and put that di-\n    rectory in my %PATH%.\n\n    exec_macro.cmd\n\n
  \       @echo off\n\n        for /f \"usebackq tokens=*\" %%x in (`doskey /macros
  ^| perl -ne\n        \"next unless s/^%*=//; s/\\s*\\$T/\\n/g; print\"`) do %%x\n\n
  \   remove_path_dups.cmd\n\n        @echo off\n\n        for /f \"usebackq tokens=*\"
  %%x in (`perl -le \"for (split /;/,\n        $ENV{PATH}) { $p{$_} || do { $p{$_}++;
  push @p, $_ }; } print\n        join q{;}, @p\"`) do set PATH=%%x\n\n    strawberry_maint_macros.cmd\n\n
  \       @echo off\n\n        doskey pclean=perl Makefile.PL$Tdmake realclean$Tdel
  /F MANIFEST\n\n        doskey pinst=perl Makefile.PL$Tdmake$Tdmake install$Tcall
  exec_-\n        macro pclean\n\n        doskey pprepare=rmdir /S inc $Tdel /F MANIFEST$Tperl
  Make-\n        file.PL$Tdmake manifest$Tperl Makefile.PL$Tdmake\n\n        doskey
  pdist=call exec_macro pprepare$Tdmake dist\n\n        doskey pupload=call exec_macro
  pprepare$Tdmake upload\n\n    activeperl_maint_macros.cmd\n\n        @echo off\n\n
  \       doskey pclean=perl Makefile.PL$Tnmake realclean$Tdel /F MANIFEST\n\n        doskey
  pinst=perl Makefile.PL$Tnmake$Tnmake install$Tcall exec_-\n        macro pclean\n\n
  \       doskey pprepare=rmdir /S inc $Tdel /F MANIFEST$Tperl Make-\n        file.PL$Tnmake
  manifest$Tperl Makefile.PL$Tnmake\n\n        doskey pdist=call exec_macro pprepare$Tnmake
  dist\n\n        doskey pupload=call exec_macro pprepare$Tnmake upload\n\n    These
  use perl, I'll fix them to use something native like power-\n    shell or wsh at
  some point, but I don't know those languages yet.\n"
title: My cmd.exe Profile
type: pod
uri: http://blog.cachemiss.com/articles/My%20cmd.exe%20Profile.pod
xhtml: "<div class=\"pod\">\n<p>I wanted to set up a cmd.exe environment similar to
  my msys .bashrc for msysGit\n(<a href=\"http://code.google.com/p/msysgit/\">http://code.google.com/p/msysgit/</a>),
  to set up environment variables and\ndoskey macros (aliases.)</p>\n<p>This post
  will show you some techniques for doing this.</p>\n<p>As Larry Wall said, &quot;it's
  easier to port a shell than a shell script.&quot;</p>\n<p>I use Console2 for my
  various command prompts (msysgit, powershell, cmd.exe...)\nyou can get it here:
  <a href=\"https://sourceforge.net/projects/console/\">https://sourceforge.net/projects/console/</a>.</p>\n<p>First,
  how do we tell cmd.exe to run a script on startup? There are two ways,\nthe way
  I use is with the /K option to run a batch file and continue. Another\noption is
  to set a registry key, see <code>cmd /?</code> for what registry key to set.</p>\n<p>Make
  a file called .cmd_profile.cmd in your %HOME%, then configure your cmd.exe\ntabs
  in Console2 to something like this:</p>\n<pre>c:\\windows\\system32\\cmd.exe /K
  c:\\Users\\rkitover\\.cmd_profile.cmd\n</pre>\n<p>Or make a shortcut on your desktop
  with this command line.</p>\n<p>Or set that registry to the location of your profile
  script.</p>\n<p>My .cmd_profile.cmd looks like this:</p>\n<pre>@echo off\n\nREM
  Presumably we will only use real consoles with this profile.\nREM And perl readline
  only works with TERM=dumb .\nREM Set this to 'cygwin' to work with cygwin utilities.\nset
  TERM=dumb\n\ndoskey use_strawberry64=^\n    set PATH=c:\\strawberry\\perl\\site\\bin;c:\\strawberry\\perl\\bin;c:\\strawberry\\c\\bin;%PATH%^\n
  \   $Tcall remove_path_dups^\n    $Tcall strawberry_maint_macros\n\ndoskey use_activeperl64=^\n
  \   set PATH=C:\\Perl64\\site\\bin;C:\\Perl64\\bin;C:\\Program Files (x86)\\Microsoft
  Visual Studio 10.0\\VC\\bin\\amd64;%PATH%^\n    $Tcall remove_path_dups^\n    $Tset
  LIB=C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib\\x64;C:\\Program Files
  (x86)\\Microsoft Visual Studio 10.0\\VC\\lib\\amd64^\n    $Tcall activestate_maint_macros\n\ndoskey
  use_activeperl32=^\n    set PATH=C:\\Perl\\site\\bin;C:\\Perl\\bin;c:\\Program Files
  (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE;c:\\Program Files (x86)\\Microsoft
  Visual Studio 10.0\\VC\\bin;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Tools;c:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;c:\\Windows\\Microsoft.NET\\Framework\\v3.5;c:\\Program
  Files (x86)\\Microsoft Visual Studio 10.0\\VC\\VCPackages;c:\\Program Files (x86)\\Microsoft
  SDKs\\Windows\\v7.0A\\bin\\NETFX 4.0 Tools;c:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin;%PATH%^\n
  \   $Tcall remove_path_dups^\n    $Tset LIB=C:\\Program Files (x86)\\Microsoft Visual
  Studio 10.0\\VC\\lib;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\lib^\n
  \   $Tset LIBPATH=c:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;C:\\Program
  Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB^\n    $Tcall activestate_maint_macros\n\ncall
  exec_macro use_activeperl32\n</pre>\n<p>Some features to notice here:</p>\n<dl>\n\t<dt>line
  continuation</dt>\n\t<dd>\n\t\t<p>The line continuation and escape character for
  certain shell metacharacters in\nbatch files is <code>^</code>.</p>\n\t</dd>\n\t<dt>doskey
  command separator</dt>\n\t<dd>\n\t\t<p>The command separator in doskey macros is
  <code>$T</code>, see <code>doskey /?</code> for more\ninformation.</p>\n\t</dd>\n\t<dt>environment
  variable expansion</dt>\n\t<dd>\n\t\t<p>Environment variables are expanded immediately
  when the batch file is executed,\nnot when the command using them runs. Here the
  %PATH% I use is the %PATH% my\ncmd.exe starts with, always. This is not what happens
  in my .bashrc, but it\nsuits my purposes in this case well enough that I haven't
  fixed it yet.</p>\n\t</dd>\n</dl>\n<p>There are a couple of supporting .cmd utilities
  to go along with this profile. I\nput them into C:\\Users\\rkitover\\bin and put
  that directory in my %PATH%.</p>\n<dl>\n\t<dt>exec_macro.cmd</dt>\n\t<dd>\n<pre>@echo
  off\n\nfor /f &quot;usebackq tokens=*&quot; %%x in (`doskey /macros ^| perl -ne
  &quot;next unless s/^%*=//; s/\\s*\\$T/\\n/g; print&quot;`) do %%x\n</pre>\n\t</dd>\n\t<dt>remove_path_dups.cmd</dt>\n\t<dd>\n<pre>@echo
  off\n\nfor /f &quot;usebackq tokens=*&quot; %%x in (`perl -le &quot;for (split /;/,
  $ENV{PATH}) { $p{$_} || do { $p{$_}++; push @p, $_ }; } print join q{;}, @p&quot;`)
  do set PATH=%%x\n</pre>\n\t</dd>\n\t<dt>strawberry_maint_macros.cmd</dt>\n\t<dd>\n<pre>@echo
  off\n\ndoskey pclean=perl Makefile.PL$Tdmake realclean$Tdel /F MANIFEST\n\ndoskey
  pinst=perl Makefile.PL$Tdmake$Tdmake install$Tcall exec_macro pclean\n\ndoskey pprepare=rmdir
  /S inc $Tdel /F MANIFEST$Tperl Makefile.PL$Tdmake manifest$Tperl Makefile.PL$Tdmake\n\ndoskey
  pdist=call exec_macro pprepare$Tdmake dist\n\ndoskey pupload=call exec_macro pprepare$Tdmake
  upload\n</pre>\n\t</dd>\n\t<dt>activeperl_maint_macros.cmd</dt>\n\t<dd>\n<pre>@echo
  off\n\ndoskey pclean=perl Makefile.PL$Tnmake realclean$Tdel /F MANIFEST\n\ndoskey
  pinst=perl Makefile.PL$Tnmake$Tnmake install$Tcall exec_macro pclean\n\ndoskey pprepare=rmdir
  /S inc $Tdel /F MANIFEST$Tperl Makefile.PL$Tnmake manifest$Tperl Makefile.PL$Tnmake\n\ndoskey
  pdist=call exec_macro pprepare$Tnmake dist\n\ndoskey pupload=call exec_macro pprepare$Tnmake
  upload\n</pre>\n\t</dd>\n</dl>\n<p>These use perl, I'll fix them to use something
  native like powershell or wsh at\nsome point, but I don't know those languages yet.</p>\n\n\n</div>"
---
author:
  email: rkitover@io.com
  keyid: ecfd90663e4a2921
  name: Rafael Kitover
categories: []
date: 2011-01-26T00:20:35Z
guid: 32470148-28E2-11E0-AFA1-6ED120E7A903
modified: 2011-04-24T00:10:52Z
raw: "-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\n=pod\n\nIf you use msysGit
  L<http://code.google.com/p/msysgit/> with Cygwin\nL<http://www.cygwin.com/>, here
  are some hacks to make the two environments more\ninteroperable, and to make Cygwin
  paths more interoperable with native Windows\nprograms.\n\n=head2 Paths\n\nFirst,
  let's change the C</cygdrive> mount point in Cygwin so that drive-qualified\npaths
  are more like they are in msys, e.g. instead of C</cygdrive/c/foo> we want\nC</c/foo>.\n\nIn
  the Cygwin shell, do this:\n\n  lang:bash\n  mount -c /\n\nIn C</etc/fstab> change
  the cygdrive mountpoint as well:\n\n  lang:fstab\n  none / cygdrive binary,posix=0,user
  0 0\n\nNow, open a C<cmd.exe> window with Administrator privileges, and run the\nfollowing:\n\n
  \ lang:bash\n  mklink /D C:\\c C:\\\n\nrepeat for any other drives you want aliased
  this way.\n\nThe reason for this is so that cygwin paths such as C</c/foo/bar> work
  with\nnative Windows programs as well.\n\n=head2 Git Configuration\n\nIn Cygwin
  git, run this command:\n\n  lang:bash\n  git config --global core.autocrlf true\n\nThis
  is necessary if you want to run git commands on your msysGit clones,\nbecause msysGit
  defaults this option to on, otherwise you will make erroneous\ncommits with the
  wrong line endings.\n\nOccasionally you may need to convert a project to UNIX line
  endings. To do so\nuse this procedure:\n\n  lang:bash\n  git config core.autocrlf
  false\n  rm .git/index\n  git checkout -f HEAD\n\nIn both Cygwin git and msysGit
  run the following:\n\n  lang:bash\n  git config --global core.filemode false\n\nTo
  ignore +x bits on files.\n\nYou will also need to run:\n\n  lang:bash\n  git config
  core.filemode false\n\nin every project.\n\n=cut\n-----BEGIN PGP SIGNATURE-----\nVersion:
  GnuPG v1.4.10 (GNU/Linux)\n\niQCVAwUBTbNqiuz9kGY+SikhAQK3FgP/WaGX1xnVYAHSxdt+psuTVwMnaab5fbKY\nWi/fELTl5WoweKZNgf7zjdaw0UIG0NbBGK9fVEhJQ+OLEbr+s/5wQVjXt3c/Tub1\ngI7fcadGgbgB7LQ0hVrMnX1Arg3enP2hFfblOUhk/hlN1c2K9R6xS73IXXdruRuk\nUQG5amDlKJ4=\n=tzY8\n-----END
  PGP SIGNATURE-----\n"
signed: 1
summary: ' If you use msysGit http://code.google.com/p/msysgit/ with Cygwin http://www.cygwin.com/,
  here …'
tags:
- msysgit: 0
- git: 0
- line-endings: 0
- cygwin: 0
- msys: 0
- paths: 0
text: "    If you use msysGit http://code.google.com/p/msysgit/ with Cygwin\n    http://www.cygwin.com/,
  here are some hacks to make the two environ-\n    ments more interoperable, and
  to make Cygwin paths more interopera-\n    ble with native Windows programs.\n\n
  Paths\n\n    First, let's change the /cygdrive mount point in Cygwin so that\n    drive-qualified
  paths are more like they are in msys, e.g. instead\n    of /cygdrive/c/foo we want
  /c/foo.\n\n    In the Cygwin shell, do this:\n\n      lang:bash mount -c /\n\n    In
  /etc/fstab change the cygdrive mountpoint as well:\n\n      lang:fstab none / cygdrive
  binary,posix=0,user 0 0\n\n    Now, open a cmd.exe window with Administrator privileges,
  and run\n    the following:\n\n      lang:bash mklink /D C:\\c C:\\\n\n    repeat
  for any other drives you want aliased this way.\n\n    The reason for this is so
  that cygwin paths such as /c/foo/bar work\n    with native Windows programs as well.\n\n
  Git Configuration\n\n    In Cygwin git, run this command:\n\n      lang:bash git
  config --global core.autocrlf true\n\n    This is necessary if you want to run git
  commands on your msysGit\n    clones, because msysGit defaults this option to on,
  otherwise you\n    will make erroneous commits with the wrong line endings.\n\n
  \   Occasionally you may need to convert a project to UNIX line endings.\n    To
  do so use this procedure:\n\n      lang:bash git config core.autocrlf false rm .git/index
  git check-\n      out -f HEAD\n\n    In both Cygwin git and msysGit run the following:\n\n
  \     lang:bash git config --global core.filemode false\n\n    To ignore +x bits
  on files.\n\n    You will also need to run:\n\n      lang:bash git config core.filemode
  false\n\n    in every project.\n"
title: Using msysGit with Cygwin
type: pod
uri: http://blog.cachemiss.com/articles/Using%20msysGit%20with%20Cygwin.pod
xhtml: '<div class="pod">

  <p>If you use msysGit <a href="http://code.google.com/p/msysgit/">http://code.google.com/p/msysgit/</a>
  with Cygwin

  <a href="http://www.cygwin.com/">http://www.cygwin.com/</a>, here are some hacks
  to make the two environments more

  interoperable, and to make Cygwin paths more interoperable with native Windows

  programs.</p>

  <h4 id="Paths">Paths</h4>

  <div id="Paths_CONTENT">

  <p>First, let''s change the <code>/cygdrive</code> mount point in Cygwin so that
  drive-qualified

  paths are more like they are in msys, e.g. instead of <code>/cygdrive/c/foo</code>
  we want

  <code>/c/foo</code>.</p>

  <p>In the Cygwin shell, do this:</p>

  <pre><span class="BString">mount</span><span class="Normal"> -c /</span>

  </pre>

  <p>In <code>/etc/fstab</code> change the cygdrive mountpoint as well:</p>

  <pre>none / cygdrive binary,posix=0,user 0 0

  </pre>

  <p>Now, open a <code>cmd.exe</code> window with Administrator privileges, and run
  the

  following:</p>

  <pre><span class="Normal">mklink /D C:\c C:</span><span class="Keyword">\</span>

  </pre>

  <p>repeat for any other drives you want aliased this way.</p>

  <p>The reason for this is so that cygwin paths such as <code>/c/foo/bar</code> work
  with

  native Windows programs as well.</p>


  </div>

  <h4 id="Git_Configuration">Git Configuration</h4>

  <div id="Git_Configuration_CONTENT">

  <p>In Cygwin git, run this command:</p>

  <pre><span class="Normal">git config --global core.autocrlf </span><span class="BString">true</span>

  </pre>

  <p>This is necessary if you want to run git commands on your msysGit clones,

  because msysGit defaults this option to on, otherwise you will make erroneous

  commits with the wrong line endings.</p>

  <p>Occasionally you may need to convert a project to UNIX line endings. To do so

  use this procedure:</p>

  <pre><span class="Normal">git config core.autocrlf </span><span class="BString">false</span><span
  class="Normal">

  </span><span class="BString">rm</span><span class="Normal"> .git/index</span><span
  class="Normal">

  </span><span class="Normal">git checkout -f </span><span class="BString">HEAD</span>

  </pre>

  <p>In both Cygwin git and msysGit run the following:</p>

  <pre><span class="Normal">git config --global core.filemode </span><span class="BString">false</span>

  </pre>

  <p>To ignore +x bits on files.</p>

  <p>You will also need to run:</p>

  <pre><span class="Normal">git config core.filemode </span><span class="BString">false</span>

  </pre>

  <p>in every project.</p>


  </div>

  </div>'

