Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Portable perl: usb thumbdrive

by zzspectrez (Hermit)
on Aug 18, 2005 at 04:56 UTC ( [id://484676]=perlmeditation: print w/replies, xml ) Need Help??

Perl to go.

I dont work in the computer field... Actually, I work in the medical field. However, in my downtime at work I sometimes like to play around with ideas in perl. I have computer access, but no access to install software.

In the past, I have run ssh client from a usb thumbdrive to my computer at home. However, I really didnt like the idea of my password possibly being logged since there is monitoring software.

Well, how about a full perl distribution on a thumbdrive? Talk about portable. I could take my perl, modules, editor and code with me.

Here is what I wanted.

I wanted to be able to insert my thumbdrive click on a shortcut and have cmd prompt pop-up with perl, my editor, and unix utils in my path. Here is what I did to get it working.

The systems I wanted to use this on would be running either windows XP or Windows 2000. Instead of messing with trying to get Activestate to work I compiled perl from the source.

The stuff

First I installed mingw which was used to compile perl. The procedure was quite simple, install the software and add to your path. Next download dmake and add it to your path.

If you dont want to install perl to c:\perl then you need to edit the file makefile.mk. The config file is allready setup to use with mingw right out of the box. Then fire up a cmd shell, and do the following:

c:\src\perl-5.8.7> cd win32 c:\src\perl-5.8.7> dmake c:\src\perl-5.8.7> dmake test c:\src\perl-5.8.7> dmake install

NOTE:
If you install the unix utilities and add to your path beware of the following problem. The unix utilities adds a program called type.exe that will cause errors on the following tests:

  • ../ext/IO/t/io_dup.t
  • comp/multiline.t
  • io/dup.t
This is due to how the tests try to call 'type' using the backticks and invoking the installed type.exe instead of the shell's version. Remove the type.exe from path and you are fine.

Then you just copy over the c:\perl over to your thumbdrive. Perl to go. To save some space you can also delete the html docs.

I also then added the unix utils to the thumbdrive and also the vim editor.

The next problem was how to deal with the drive allways being on a different volume from computer to computer.. One computer it would be drive I: the other e: for example... And how can I set the path to my binaries??

My solution is one batch file and a small perl script.

Batch file: start-cmd.bat

programs\perl\bin\perl.exe src\perl\autostart.pl

Perl file: autostart.pl

use strict; use warnings; use File::Spec; my $cur_dir = File::Spec->curdir(); $cur_dir = File::Spec->rel2abs unless ( File::Spec->file_name_is_absolute($cur_dir) ); my $drive = (File::Spec->splitpath($cur_dir))[0]; $drive .= '\\'; my @paths = ( 'programs\\perl\\bin', 'programs\\bin', 'programs\\dmake', 'programs\\usr\local\wbin' ); my $path = '%PATH%;'; foreach my $item (@paths) { my $tmp = File::Spec->catpath($drive,$item); $path .= File::Spec->canonpath($tmp) . ';'; } my $path_cmd = "set path=$path"; print "Current directory: $cur_dir\n"; print "Current drive: $drive\n"; print "Path to be set: $path_cmd\n"; exec ("cmd.exe /K $path_cmd") or die "Couldn't exec cmd.exe: $!\n";

Tada!!! Now I just double-click on the batch file start-cmd.bat and I have a cmd window with the path set to all of my binaries. No matter what drive it is mapped to I have a nice portable perl development environment to go. :)

zzSPECTREz

Replies are listed 'Best First'.
Re: Portable perl: usb thumbdrive
by Ctrl-z (Friar) on Aug 18, 2005 at 10:02 UTC
    Nice. You might also be interested in tinyperl. It saves space by keeping the lib directory in a zip file and can compile scripts into executables.



    time was, I could move my arms like a bird and...
Re: Portable perl: usb thumbdrive
by Eyck (Priest) on Aug 18, 2005 at 08:19 UTC
[OT] Re: Portable perl: usb thumbdrive
by salva (Canon) on Aug 18, 2005 at 10:58 UTC
    In the past, I have run ssh client from a usb thumbdrive to my computer at home. However, I really didnt like the idea of my password possibly being logged since there is monitoring software.

    which kind of monitoring?

    Somebody sniffing the network would not be able to capture your password because all ssh comunications are encrypted and anyway, the password is never transmited to the remote server.

    If the monitoring you are talking about is some kind of spyware running on your computer, able to capture keypresses and alike, then you could install some one-time-passwords login system like opie on your server.

      All the machines at my work have a software similar to PCANYWHERE where the IT department can either monitor or take control of your machine. I doubt they log passwords to websites, etc... but they could, and I try to be paranoid about passwords.

      I had thought of setting up s/key which is part of openbsd ( my home server is a openbsd server ) but keeping track of one-time passwords is too much hassle, and I didnt want to have a continual ssh connection running and find out later I am violating some internet/security policy.

      All, in all, the portable perl solution is much simpler..

      zzSPECTREz
Re: Portable perl: usb thumbdrive
by Courage (Parson) on Aug 18, 2005 at 12:33 UTC
    I have following to advice to you, 100% based on my own practices:
    • use LiveCD linuxes: you boot from CD with your USB pen inserted, play w/o installing anything with Perl. When you go, you'll data storied to USB. I use knoppix, but this could be anything else. Some linuxes boot from USB device and are located entirely there.
    • Use WinCE with perl on it. Sometimes I use it within 5-min breaks at lunch, or in any unexpected places.
    But for usage Perl from your own USB stick - I would advice using ActivePerl, because it has many modules bundled, so you do not need to recompile them. ActivePerl could be perfectly moved from one directory to another easily, without editing any files.

      I have software on the machine I must have access to for doing my job, so switching back in forth between linux and windows is too much hassle.

      Second, 98% of the machines have the bios locked down and cd booting disabled to prevent such practices.

      On the flip side, we are able to mount and use usb pen drives.

      What do you mean WinCE?? Are you talking about a handheld?

      zzSPECTREz
        Indeed, booting from your own media is not always possible.

        When speaking about WinCE, I namely had in mind perl on handheld, see http://perlce.sourceforge.net/cgi-bin/perlce-tcltkce-wiki.pl?Happy_Screenshots
        Should I mention that I wrote my CJK-English dictionary with unihan.txt interface while I was bored in a fitness-centre? :):):)
        Other two there also?

        However "perlce" on Wince has its own sloppy places, but let us leave listing them onto another meditation :)

        Best regards,
        Courage, the Cowardly Dog

Re: Portable perl: usb thumbdrive
by willyyam (Priest) on Aug 18, 2005 at 15:42 UTC

    Nicely done. I have a fondness for the live Linux distributions to do this, but your solution is more Windows-centric. This is both a recommendation for your method and my harshest criticism of it :-)

    Something I recently read about that I like the look of is Project Black Dog, a USB-based Linux server with a fingerprint scanner that takes over the hardware of it's host machine when you plug it in - much like a Knoppix-type system. Between the fingerprint scanner and GnuPG you could be pretty sure your data and activities are safe from prying eyes.

Re: Portable perl: usb thumbdrive
by davidrw (Prior) on Aug 18, 2005 at 11:26 UTC
    What's the size footprint of the pieces copied to the usb drive?

      My usb drive is filled as follows:

      • Perl: 35.5 Megs
      • dmake: 288 KB
      • Unix Utils: 5 Megs
      • Portable Firefox: 7 Megs

      So I am using about 43 Megs for programs on my 256 meg memory stick and the rest is for data.

Re: Portable perl: usb thumbdrive
by Anonymous Monk on Apr 06, 2009 at 08:10 UTC
    I am compiling & testing perl 5.10.0 Guys, if you're still having errors EVEN without UNXUTILS in your path, do a complete hard disk search for type.exe. Turns out that long ago I dropped WBIN into the "C:\windows\system32" folder long ago and forgot. After removing it from the PATH, DMAKE TEST is now running great. Still waiting for test completion.
Re: Portable perl: usb thumbdrive
by Anonymous Monk on Aug 30, 2012 at 04:24 UTC
    Hi Monks.

    Strawberry Perl has a version called the "PortableZip edition" (both 32 and 64 bit versions).

    Strawberry Perl PortableZip

    Hope this helps.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://484676]
Approved by greenFox
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-03-19 06:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found