Please put down the flame throwers and pitchforks momentarily.
I have read the standard methods to perform this old trick.
They just don't work on the new Ubuntu 15.10.


Goal:

Get ~/bin/psr.pl et al. to run as just psr Perl Search-n-Replace


Method:

Add ~./bin to $ENV{PATH}
Add shebang line pointing to /usr/local/bin/perl (5.22.1)
Tried aliasing /usr/bin/perl to /usr/local/bin/perl, broke apt-get
gave psr.pl 744 permissions, owned by me
running /bin/bash shell


Result:

psr.pl works fine, psr -> No command 'psr' found, did you mean:

Limparound (can't fail!):

Create ~/bin/psh dir
create psr.sh wrapper for psr.pl (modeled after horrible dos)
Place psh directory ahead of ~/bin in path
run psr.sh to get to psr.pl
result => SNAFU



TEST CASE:

]] SORRY FOR NANO-)CODE( SIZE [[ brianp@raptor:~$ eng path [[ env | grep -i => check PATH]] PATH=/home/brianp/bin/psh:/home/brianp/bin:/usr/local/sbin:/usr/local/ +bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games brianp@raptor:~$ fcmd.pl psr [[ Search $ENV{PATH} for target ]] /home/brianp/bin/psh/psr.sh /home/brianp/bin/psr.pl brianp@raptor:~$ ll `fcmd.pl psr` [[ Check paths and exec perms ]] -rwxr--r-- 1 brianp brianp 62 Jan 30 11:30 /home/brianp/bin/psh/psr.s +h* -rwxr--r-- 1 brianp brianp 217 Sep 5 2001 /home/brianp/bin/psr.pl* brianp@raptor:~$ cat `fcmd.pl psr` [[ check for [more] buggy code ] +] #!/bin/sh /usr/local/bin/perl -w /home/brianp/bin/psr.pl "$@" ... #!/usr/local/bin/perl -w # PSR - Perl Search & Replace. Replacement for the #%%&^*# braindead s +ed. $target = $ARGV[0]; # Target to search for is the first argument. for(<STDIN>) { eval $target; print $_; } [[ Check for actual functionality... Filter BLANK lines ]] brianp@raptor:~$ /usr/local/bin/perl -v | psr.sh "s/^\s*$//" | head -n + 2 This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-li +nux Copyright 1987-2015, Larry Wall [[ psr.sh does filter top blank line! + ]] brianp@raptor:~$ /usr/local/bin/perl -v | head -n 2 [[ blank line starts spew ]] This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-li +nux brianp@raptor:~$ /usr/local/bin/perl -v | psr.pl "s/^\s*$//" | head -n + 2 This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-li +nux Copyright 1987-2015, Larry Wall [[ blank line gone, Larry's Baaaaaaaa +k ]] brianp@raptor:~$ psr 2>&1 | head -n1 No command 'psr' found, did you mean: brianp@raptor:~$ whoami brianp brianp@raptor:~$ eng shell SHELL=/bin/bash brianp@raptor:~$ cat /etc/debian_version jessie/sid [[ Ubuntu 15.10 -> Wily Werewolf ??] brianp@raptor:~$ uname -a Linux raptor 4.2.0-25-generic #30-Ubuntu SMP Mon Jan 18 12:31:50 UTC 2 +016 x86_64 x86_64 x86_64 GNU/Linux brianp@raptor:~$ ll /bin/sh [[ Not regular sh/bash]] lrwxrwxrwx 1 root root 4 Jan 22 23:48 /bin/sh -> dash* [[ shell made by iceholes to confound infidles? ]] brianp@raptor:~$ ll `which dash` -rwxr-xr-x 1 root root 125400 Jun 4 2015 /bin/dash*

Confounded for sure! ============================================ 1nickt, >> Why do you think you can execute the program without using its full name?
A) it's in the path,
B) It has exec permissions
C) the `file` command identifies it as an 'ASCII text exec'
C.5) The #! line tells it everything it needs
D) if it works on dos, it has to work on *_Linux_*! Surely!!
E) Slick sys admins use magic to keep the .pl ext
and make it run like *.exe on win; works just the
same with/without the .exe. Standard Practice! F) Linux does not care about file extensions G) The simple procedure for .sh is well documented:
http://stackoverflow.com/questions/2999448/executing-shell-script-without-calling-sh-implicitly

Maybe they used links. This can not be a hard cat to skin!!!
If you ask your "intelligent assistant" to run "psr",
which is a more satisfactory response:
"HUH???" or
"I'll Pounce on psr.pl, STAT!"

I have had the convenience at numerous contracts,
I have it now on windoz.
I shall have it on my new, WizBang Workstation if I
have to hack the Kernel to the nub in the process.

brianp@raptor:~$ file `fcmd.pl psr` /home/brianp/bin/psh/psr.sh: POSIX shell script, ASCII text executable /home/brianp/bin/psr.pl: a /usr/local/bin/perl -w script, ASCII te +xt executable, with CRLF line terminators

In reply to Perl script w/o .pl extension broken on Ubuntu? by BrianP

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.