Tag Archives: fork

Renaming to Aid with Numerical File Sorts Command Line and Curl Tutorial

Yesterday’s Renaming to Aid with Numerical File Sorts Actions Tutorial had good interaction characteristics, in our books (… but as of this news bulletin, not in our pamphlettes and we hope to resume normal transmission forthwith like …) but, out of PHP’s three modes of use (which we talked about at CSH/KSH/PHP Numerical Bubble Sort Tutorial) … Surfing the Net … is very interactive and we can use HTML form elements for navigation purposes … for example, URL (on local MAMP (Mac) Apache/PHP/MySql web server) … http://localhost:8888/rename_to_aid_sorting.php?dirone=.%2F&dirtwo=Django_Python-&asteriskybit=%5B0123456789%5D*.* … but more than likely the environment where users will think to use this PHP application is via … Command Line Usage … for example, be in MAMP’s /Applications/MAMP/htdocs/ directory with … php rename_to_aid_sorting.php ./Django_Python- # or … Curl Usage … for example, be in MAMP’s /Applications/MAMP/htdocs/ directory with … curl http://localhost:8888/rename_to_aid_sorting.php?inspec=./Django_Python- # you can see in action below … Up near the top of the code processing input parameters the PHP code differentiation goes … if (isset($_GET[‘inspec’]) && !isset($_GET[‘dirone’]) && !isset($_GET[‘dirtwo’])) { // reserved for curl instructions // Curl usage is hard to differentiate from “Surfing the Net” … they both ask for a URL whereas Command Line has arguments … so sometimes Curl usage is best // organized with one $_GET[] (for us $_GET[‘inspec’]) and limit it to just the one. Why so? Well, “&” on command line is awkward. // To involve more than one argument in Curl use an internal delimitation character like ^ or ! perhaps to proceed. We were able to just keep it to one today. // // … curl argument processing code goes here // } else if ($argv) { // command line usage // // … command line argument processing code goes here // } else { // surfing the net usage // // … surfing the net argument processing code goes here // } … and down near the bottom, differentiation regarding the look of the outputs, it goes … if ($argv || (isset($_GET[‘inspec’]) && !isset($_GET[‘dirone’]) && !isset($_GET[‘dirtwo’]))) { // command line or curl … just show commands for user to try or not … they may want a pipe like ” | tee do_these_renames.ksh” (and then follow up “ksh -x do_these_renames.ksh”) $outp=””; if (strpos(strtoupper((” . PHP_OS)), “WINDOW”) !== false) { $lines=explode(“\nren” . “ame “); for ($oi=1; $oi<sizeof($lines); $oi++) { $outp.=”ren” . “ame ” . explode(“\n”, $lines[$oi])[0] . “\n”; } } else { … Continue reading →

Posted in eLearning, Event-Driven Programming, Software, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment