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*
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |