Remy José Cano on Fri, 12 Jul 2019 19:28:14 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

On saving clicks and keystrokes everyday...


Greetings!,

Imagine just by a second that you are working on a Windows machine and
you open a CMD.exe shell instance and type:

"surf 1,3"

(without the quotes, of course) and then by hitting ENTER, an
"incognito" instance of Google's Chrome browser gets opened in front
of you, loading your personal online bank login's page... Well, this
can be done with system() through GP thanks to a little bit of
sourcecode similar to what, today i am glad of sharing with you...

This is a PARI/GP "tool" i wrote because i found that attractive and
interesting to work things in such way when using Windows...

[----------[filename:surf_gp.txt]------*file Content begins here*------------]

/* R. J. Cano, Jul 13 2019 */

cmdInvokation=[ ["Google`s Chrome web
browser","C:\\Users\\helpdesk\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe
--incognito "] ];
cmdArgs=[ ["Empty/Void.",""], ["Get current time and date at: La Paz,
Bolivia.","https://www.worldtimeserver.com/current_time_in_BO.aspx";],
["\"Mercantil en linea personas\" Online
bank.","https://www30.mercantilbanco.com/olb/TimeoutFrame";], ["Sign-in
into Google accounts.","https://accounts.google.com/";], ["Just perform
a Google search.","www.google.com"] ];

addhelp(surf,"surf() Implements a simple hash-like menu for system()
calls based upon customized presets. Call it with an empty argument
for displaying its menu and usage.");

prnSptr({X=[]},{nl=0})={if(!#X,for(k=1,20,print1("*")),for(k=1,X[2],print1(X[1])));if(nl,print1("\n"))}

surf({Y=[]})=if(!#Y,prnSptr(["-",40],1);print("\tDefined
invokations:");for(i=1,#cmdInvokation,print(i")
"cmdInvokation[i][1]));print("\tDefined
actions/requests/instructions:");for(j=1,#cmdArgs,print(j")
"cmdArgs[j][1]));prnSptr(["-",40],1);print("\nUsage 1:
surf([cmdInvokation,cmdArgs]) under GP;\nUsage 2: surf m,n under
Windows CMD.exe
shell.\n"),system(concat(cmdInvokation[Y[1]][2],cmdArgs[Y[2]][2])));

[----------[filename:surf_gp.txt]------*file Content ends here*------------]

This is complemented with a .bat script like this:

[----------[filename:surf.bat]----------*file Content starts here*------------]
@echo off
set savePath=%cd%
%homedrive%
cd %userprofile%
REM md .surf.gp
cd .surf.gp
type surf_gp.txt    > call-surf_gp.txt
echo surf([ %* ]); >> call-surf_gp.txt
echo quit();       >> call-surf_gp.txt
call gp -f -q         call-surf_gp.txt
%savePath:~0,2%
cd %savePath%
[----------[filename:surf.bat]----------*file Content ends here*------------]

It is assumed that by some mean you are allowed to change the
specification of Windows so called "environment variable" named
"PATH", at least the version of it used there by your user account, by
doing it in a customary way where the GP.exe executable is reachable
from your command line shell... For instance my personal choice is
what i call the "less invasive" method consisting of creating a .lnk
shortcut (let us say at our Desktop) from where CMD.exe is invoked
with the "k" option for executing before than anything else, another
batch script where your custom enviroment settings are defined and
implemented as that script itself...

Notice that everything here is done without requiring UAC privileges :-)

The remaining editing task have to do with deciding those websites and
URLs that are most used by you, then including them fill-in the
corresponding vector in "surf_gp.txt"; Apropos notice that, by
definition this is not restricted only to invoke a web browser... you
are welcome to (carefully) use it for much more than that...

Precisely like what i need when privately browsing at my university,
where non-admin users/workers are not allowed to create accounts,
manage disk quotas or get UAC privileges. Surely some of you would
find all this unnecessary from your own contexts/viewpoints and i
respect that. But honestly talking i often need dumb things like this
one.

Cheers,

R. J.