Download and Copy or Move Server Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

Download and Copy or Move Server Tutorial

Download and Copy or Move Server Tutorial

Yesterdayโ€™s Download and Copy or Move Primer Tutorial was all about the โ€œclient sideโ€ of โ€ฆ

  • the โ€œserverโ€ side web applications/pages โ€ฆ and โ€ฆ
  • a โ€œclientโ€ side listener (like we talked about with Korn Shell listeners with Pandoc Document Conversion Email Tutorial)

โ€ฆ and weโ€™ve just โ€œtweakedโ€ (albeit, very importantly, in our books (โ€ฆ but the pamphlettes are still not playing ball)) to ensure no โ€œfile clobberingโ€ takes place so that the Korn Shell now does โ€ฆ



suf=""

isuf=-1

while [ -f "${dpath}/${brest}${suf}" ]; do

((isuf=isuf+1))

suf="_${isuf}"

done

if [ ! -z "$suf" ]; then

echo "mv ${dpath}/${brest} ${dpath}/${brest}${suf} # `date`" >> download_to_place.out

mv ${dpath}/${brest} ${dpath}/${brest}${suf} >> download_to_place.out 2>> download_to_place.err

fi

โ€ฆ in download_copierksh download_copierโšซksh Korn Shell scripting on our macOS operating system โ€œclientโ€.

But today is mainly about filling in the missing bits on the โ€œserverโ€ side. This (need for a) โ€œconduitโ€ we referred to yesterday is because we accept no folder paths can be mentioned at the โ€œserverโ€ end. Suppose, though, that the โ€œnon-pathedโ€ filename we supply to an โ€œaโ€ linkโ€™s โ€œdownloadโ€ attribute can be prefixed by a mildly mashed up version of that path we copy to from the Downloads folder of your โ€œclientโ€ computer or device, as you perform a โ€œdownloadโ€ via the clicking of an โ€œaโ€ link.

Well, at this blog weโ€™d already started functionality to toggle the use or not of โ€ฆ

  • โ€œaโ€ links โ€ฆ with โ€ฆ
  • โ€œhrefโ€ attribute containing โ€œGETMEโ€ โ€ฆ
  • but not โ€œdiff.phpโ€ โ€ฆ and โ€ฆ
  • โ€œdownloadโ€ attribute (the attribute necessary to โ€œdownloadโ€ rather than our default displaying of source code in a new webpage)

Were you here, then, when we published WordPress Blog Download Mode Toggler Primer Tutorial (or were you indisposed again?!) There we established an โ€œAll Postsโ€ menu โ€œToggle Download Mode from GETMEโ€ option piece of functionality to toggle between โ€ฆ

  • displaying of source code in a new webpage for GETME โ€œaโ€ links โ€ฆ versus โ€ฆ
  • use thechanged PHP toggle_downloadโšซphp in conjunction with a changed good โ€˜ol TwentyTen Theme header.php as below โ€ฆ
    <?php


    if (outs == null) {

    var dnprefix=decodeURIComponent(('' + localStorage.getItem('download_copy_to_folder')).replace(/^null$/g,'')).replace(/\+/g,' ').replace(/\\\\/g, '_').replace(/\//g, '_').replace(/\:/g, '_');

    for (idmjk=0; idmjk<admjk.length; idmjk++) {

    if (admjk[idmjk].href.indexOf('GETME') != -1 && admjk[idmjk].href.indexOf('diff.php') == -1) {



    if (origcafd < 0) { //!cafd) {

    xp=admjk[idmjk].href.split("GETME");

    prexp=xp[0].split("/");

    postprexp=prexp[-1 + prexp.length].split(".");

    extis = postprexp[-1 + postprexp.length].replace(/_/g,"").replace(/-/g,"").replace(/GETME/g,"");

    outs="//www.rjmprogramming.com.au/getmelist.htm?topoff=150&tsp=" + (Math.floor(Math.random() * 1999900) + 100) + "#" + postprexp[0] + "." + postprexp[-1 + postprexp.length].replace(extis,"").replace(extis,"").replace(extis,"") + "GETME" + extis;

    aorig=admjk[idmjk].innerHTML;

    admjk[idmjk].innerHTML=admjk[idmjk].innerHTML.replace(".","<span data-alt='" + outs + "' id='spn" + cafd + "' title=\" + Code Download Table\" onclick=\"if (cafd == cafd) { cafd=" + cafd + "; changeasfordownload(); } else { window.open('" + outs + "','_blank','top=100,left=100,width=500,height=500'); } return false; \">โšซ</span>");

    if (aorig == admjk[idmjk].innerHTML && admjk[idmjk].innerHTML.indexOf('er posts') == -1) admjk[idmjk].innerHTML=admjk[idmjk].innerHTML.replace(" ","<span data-alt='" + outs + "' id='spn" + cafd + "' title=\" + Code Download Table\" onclick=\"if (cafd == cafd) { cafd=" + cafd + "; changeasfordownload(); } else { window.open('" + outs + "','_blank','top=100,left=100,width=500,height=500'); } return false; \">โšช</span>");

    cafd++;

    } else {

    prestuffs = admjk[idmjk].href.split('/');

    newaspare = admjk[idmjk].href.replace('_-GETME', '').replace('__GETME', '').replace('_GETME', '').replace(big, '');



    while (big.indexOf('-') != -1) {



    big = big.replace('-', '');



    newaspare = newaspare.replace(big, '');



    }



    big = '----------------------GETME';

    stuffs = newaspare.split('/');

    if (dnprefix != '') {

    admjk[idmjk].download = dnprefix + prestuffs[stuffs.length - 1];

    } else {


    admjk[idmjk].download = dnprefix + stuffs[stuffs.length - 1];

    }

    admjk[idmjk].title = "(Really download) " + admjk[idmjk].title + ' ... welcome to the long hover functionality that shows allows for a Download Mode for the blog that can be toggled';

    admjk[idmjk].onmouseover = " getDownloadMode(); ";

    admjk[idmjk].onmouseout = " yehBut(); ";

    admjk[idmjk].ontouchstart = " getDownloadMode(); ";

    admjk[idmjk].ontouchend = " yehBut(); ";

    }

    } else if (admjk[idmjk].href.indexOf('GETME') != -1 && origcafd < 0) { //!cafd) {

    xp=admjk[idmjk].href.split("GETME");

    prexp=xp[0].split("/");

    postprexp=prexp[-1 + prexp.length].split(".");

    extis = postprexp[-1 + postprexp.length].replace(/_/g,"").replace(/-/g,"").replace(/GETME/g,"");

    outs="//www.rjmprogramming.com.au/getmelist.htm?topoff=150&tsp=" + (Math.floor(Math.random() * 1999900) + 100) + "#" + postprexp[0] + "." + postprexp[-1 + postprexp.length].replace(extis,"").replace(extis,"").replace(extis,"") + "GETME" + extis;

    aorig=admjk[idmjk].innerHTML;

    selbitis=allthecombos((admjk[idmjk].href + '=').split('=')[1].split('&')[0]);

    admjk[idmjk].innerHTML=admjk[idmjk].innerHTML.replace(".","<span data-alt='" + outs + "' id='spn" + cafd + "' title=\" + Code Download Table\" onclick=\"if (cafd == cafd) { cafd=" + cafd + "; changeasfordownload(); } else { window.open('" + outs + "','_blank','top=100,left=100,width=500,height=500'); } return false; \"><select onchange=\" if (this.value.length > 0) { window.open(this.value,'_blank'); } return false; \" style='margin-bottom:0px;width:40px;' id='sel" + cafd + "'><option value=>โšซ</option>" + selbitis + "</select></span>");

    if (aorig == admjk[idmjk].innerHTML && admjk[idmjk].innerHTML.indexOf('er posts') == -1) admjk[idmjk].innerHTML=admjk[idmjk].innerHTML.replace(" ","<span data-alt='" + outs + "' id='spn" + cafd + "' title=\" + Code Download Table\" onclick=\"if (cafd == cafd) { cafd=" + cafd + "; changeasfordownload(); } else { window.open('" + outs + "','_blank','top=100,left=100,width=500,height=500'); } return false; \"><select onchange=\" if (this.value.length > 0) { window.open(this.value,'_blank'); } return false; \" style='margin-bottom:0px;width:40px;' id='sel" + cafd + "'><option value=>โšช</option>" + selbitis + "</select></span>");

    cafd++;

    } else if ((admjk[idmjk].innerHTML.indexOf('live run') != -1 || admjk[idmjk].title.toLowerCase().indexOf('click picture') != -1) && origcafd < 0) { //!cafd) {

    outs="//www.rjmprogramming.com.au/slideshow.html#tuts";

    admjk[idmjk].innerHTML=admjk[idmjk].innerHTML.replace(" ","<span data-alt='" + outs + "' id='spn" + cafd + "' title=\" + Cut to the Chase ... see the blog post list related to live runs and slideshows ... ie. the main point of the blog posting\" onclick=\"if (cafd == cafd) { cafd=" + cafd + "; changeasfordownload(); } else { window.open('" + outs + "','_blank','top=100,left=100,width=650,height=100'); } return false; \">โœ‚</span>");

    cafd++;

    }

    }

    }


    ?>
    โ€ฆ to, depending on whether the user specifies in the โ€œAll Postsโ€ togglingโ€™s Javascript prompt window presented, specifies a new comma separated โ€œclient folder of interest to copy toโ€ place (stored in window.localStorage), will โ€ฆ

    1. download with the GETME to the Downloads folder and copy off to the specified folder of interest (backing up as necessary) โ€ฆ versus โ€ฆ
    2. the default download mode downloads to the Downloads folder without the GETME parts

See these changes in action below, contextualizing โ€œserverโ€ and โ€œclientโ€ codes in the full picture of assisted Downloads (copied on to a folder of the userโ€™s interest) โ€ฆ



Previous relevant Download and Copy or Move Primer Tutorial is shown below.

Download and Copy or Move Primer Tutorial

Download and Copy or Move Primer Tutorial

Downloading from โ€œthe netโ€ (โ€œserver landโ€) to your computer or device (โ€œclient landโ€) is a big part of the online experience and the sharing of data over the world wide web. But have you ever wondered about the two step design of โ€ฆ

  1. download from โ€œthe netโ€ to a Downloads folder on your computer or device โ€ฆ and more often than not โ€ฆ
  2. you, the user, copies or renames this data to another location on your computer or device with command line or with operating system GUI

โ€ฆ ? Why not allow the โ€œserverโ€ side define where it can download to on the โ€œclientโ€? Well, that would be a security nightmare, allowing a highjacking of mission critical files on your computer or device. So, I get it, that is a โ€œno noโ€. But could we have a controlled โ€œarrangementโ€ between โ€ฆ

  • the โ€œserverโ€ side web applications/pages โ€ฆ and โ€ฆ
  • a โ€œclientโ€ side listener (like we talked about with Korn Shell listeners with Pandoc Document Conversion Email Tutorial)

โ€ฆ ? We think that sounds reasonable and so, today, we start our (two parts or more) mini-project (making step 2 above be considered to be programmatically handled, sometimes) designing a Korn Shell (โ€œclientโ€ side) listener to suit our macOS โ€œclientโ€ computer, executed as a background process via โ€ฆ



ksh download_copierโšซksh &

But what is the conduit, if the โ€œserverโ€ web applications/pages cannot define a destination folder other than the macOS Downloads folder for the user involved? Well, that is where we need either โ€ฆ

โ€ฆ to define a โ€œclient landโ€ folder to copy to (from the userโ€™s Download folder (receiving the downloaded data).

That first Korn Shell read command interactive input was interesting to us for a command backgrounded via the โ€œ&โ€ command suffix. But if stdin and stdout are not mentioned in the command you can answer this interactive input and then the processing the Korn Shell performs proceeds in the background. Exactly what we were hoping for, but werenโ€™t sure that this was the case!

The picture is filled in better tomorrow as we discuss the conduit in more detail tomorrow.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Event-Driven Programming, Operating System, Tutorials and tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *