# Promoting one-or-more concurent PERSONAL goals/objectives via Shell Scripting

#### gps

##### INTP 5w4 Iconoclast
In response to BurnedOut's -- as a self-professed smart ass' -- expressed revelation of interest' -- however ADD-fleeting in it's experience and expression -- in Scripting, perhaps bash scripting in particular -- I've opted to spin-off a thread ostensibly about' scripting qua scripting'.

As INTPs are prone to the allure of programming and scripting at both hobby and professional levels of participation it dawned on me that scripting' -- in the main, in general -- might be used not only to manifest geeky practical ends via a computer, but it might be used to taunt, goad, mock, lampoon, motivate, inspire and a few other verbs which may apply.
Thus the initiation of this thread in The Lounge as contrasted with Technology'.

So, I'm off to compose some posts consistent with social' intercourse suitable for a Lounge of NT/rationals prone to exercise questionable rationality.

I'll be back soon with some scripts, metaScripts, and perhaps a metaMetaScript or two.

#### gps

##### INTP 5w4 Iconoclast
I suppose one of the first community-minded features of shell scripting entails a means of creating a transaction record of one's shell script session pursuant to sharing it with others ... if not furthering the implicate motivation of re-using it with/on/for oneself as well.

Fortunately many scripting languages support such a feature.
The command which bash uses is script', though if one uses script with bash as contrasted with more lightweight scripting interpreters -- such as sh and ash -- a lot of stuff' will be captured along with the pith which one may which to (re)use later, to wit:
The downside of using script is the fact that it records all special characters, so your output file will be full of control characters and ansi escape sequences.
This can be avoided by using a very Spartan shell with script:
$SHELL=/bin/sh PS1="$ " script

So with this in mind, my first shell(s) -- bash, sh, and perhaps others -- command line is:
Code:
script --help
My 2nd will be:
Code:
man script
Having provided grounding in what the command does and some hints on how to use it we can use script' to generate contents in a file which can be copied then pasted into code tags and shared here and elsewhere.

BTW, when one is done recording one's session simply type
Code:
exit
at the prompt to stop the transcripting process.
Then one may view the contents via
Code:
cat transcript
... or alternatively via one's text editor of choice ... sed, ed, vi, vim, pico, gedit, emacs, ... whatever.

As my editor of choice is GNU emacs, the following command line launches the editor and loads the transcript file into a buffer ready for reading, editing, parsing ... whatever I choose to do with it:
Code:
emacs transcript
For those having done the experiment via bash, I recommend performing the same commands via sh, ash, tsh, csh, and/or zsh to see how the results differ with a mind towards possibly exploiting the differences towards various ends.

Hopefully this intro tutorial will serve those interested with a means of capturing their shell scripting sessions, retaining them for future use, and optionally sharing content' of interest with the rest of us.

#### gps

##### INTP 5w4 Iconoclast
As a logical' INTP -- or NT/Rational, for that matter -- how logical SEEMS one's behavior if it ONLY accomplishes one or a few objectives when MORE objectives COULD HAVE been furthered or accomplished outright?

Our friend, BurnedOut seems to have glommed onto bash as his scripting language of choice.
Yet the use of both other' and multiple -- allowing differential diagnoses, level-playing-ground comparisons, etc. -- shells can allow and incidentally provide a better, more rounded education than playing with any one-and-only-ONE shell.

Command-line interface

Shell (computing) - Wikipedia

Pipeline (Unix) - Wikipedia

Comparison of command shells - Wikipedia

So ... what if one wanted to compare shells WHILE cross linking with home work assignments, hobbies, or simply to The World Outside of programming and scripting?

When it comes to un*xoid OSes which' is our friend for discovering if and where an executable -- which command line shells ARE -- is located.

Code:
which ash
which csh
which bash
which dash
which ksh
which tsh
which zsh
which [URL="https://duckduckgo.com/?q=eshell+emacs+shell&t=ffsb&ia=web"]emacs[/URL]
And then there are programming language syntaxes which can be used for shell scripting:

python shell

javascript shell

Ruby shell

Guile scripting

As this is a publicly-accessible forum wherein a wide variety of digital equipment can access this thread and it's posts, the issue of portability across platforms arises if or when one wants to make a shell script' accessible to the masses.
With this in mind, any script' or program' which can be launched, run, or evaluated by a user clicking on a link might trump -- by convenience alone -- anything a particular shell scripter might even consider a script'.

With all this said, how might scripting' be blended with both seemingly-related and seemingly unrelated subjects, academic fields, hobbies?

One which comes to mind is the accession of this forum, this thread, or this post.
To set the stage our friends to check for the presence of tools for accessing web sites:
Code:
which [URL="https://duckduckgo.com/?q=wget&t=ffsb&ia=web"]wget[/URL]
which [URL="https://duckduckgo.com/?q=w3m+text-base+web+browser&t=ffsb&ia=web"]w3m[/URL]
which [URL="https://duckduckgo.com/?q=lynx+web+browser&t=ffsb&ia=web"]lynx[/URL]
Assuming w3m is available, we can use info' -- as well as man' and the -h help available -- can be used to acquaint oneself.
Code:
which info
info w3m
Assuming w3m is available, we can ATTEMPT to view this thread ... albeit sans malware implemented via javaScript:
Code:
w3m [URL]https://intpforum.com/showthread.php?t=26957[/URL]
All for this installment!

P.S. If you try to access this thread via w3m via some variant of the code above, please let us all know what you thought of the experience.

#### gps

##### INTP 5w4 Iconoclast
Found myself wondering whether something like unixoid shell -- as contrasted with unixoid eshell' available within emacs -- ${} expressions can be embedded within echo' command expressions a few nights ago after composing a command line to accompany my allusion to a line from the Wizard of Oz with the active ingredient being Code: ls ~ with ~ serving as a pun for home' to which there is no place like. The following morning while waking I experienced a spontaneous ideation involving something I overlooked in that 3-command stack up. I could have inserted a whoami' so that the person running the script could see which account they were using ... so as to notice whether in root or a user account with their own home' to which there is no place like. Code: whoami ; date ; pwd ; ls ~ Then it hit me that${} might be used to have the return results of an embedded-within-brackets expression inserted into an otherwise static string argument of echo', cat', or such.

Here's a line which uses the expansion of ${} within an invocation of ls' Code: ls${pwd} -la
So one may keep the form of "ls home'" while mutating the directory reference.
Code:
echo "There's no place like home! " ; ls ~ -la
ls ${pwd} -la The value returned by pwd' -- print working directory -- is evaluated as a nested expression akin to how nested parentheses are evaluated in both PEMDAS style liturgical algebra notation and most of the lisps (EG lisps and scheme minus implementations of Logo) Getting this one out off my mind before I forget about it. All for this mini demo and intro to${}
https://duckduckgo.com/?q=bash+${}+dereferencing #### BurnedOut ##### Active Member Correction : I use python more than bash. I run daily errands using bash. I am trying to grasp sed and awk now. Lurking :3 Sent from my SM-J730GM using Tapatalk #### BurnedOut ##### Active Member It's apparent that wars are constantly being raised between GPS and me, I'll taint his sacrosant post with some '%s.('pejorative_term_?')' of my own. If assuming some noob is lurking here, like me after cursory perusal of the OG posts #$gps
I'd add some ways to use programming languages as a way to insult someone with[out] (gps\'s)? perMission. It's usually exciting because then the syntactical, connotative nature of English is trimmed down to precise lines which you want to use to insult someone. For eg. 'you speak bullshit' can be made to sound more insulting by using

Import sys
If sys.argv[1]
=====Print("Hello, welcome to bullshiterv1_snapshot-build")
Else
=====Print("prayers are heard. ")

Also for noobs, again, including me, longhand scripting helps a lot. Longhand scripting when you are sitting idle. There is this one point when you can automatically detect syntax errors and runtime errors. This ability of mine placed me way ahead at my peers while writing scripts for my computer exams in java. However before you do that, make sure you practise a lot at least daily.

Sent from my SM-J730GM using Tapatalk

#### BurnedOut

##### Active Member
Ignore the grammar errors and the missing ':'s in front of if and else. Still trying to fumble with those pesky syntaxes.

Sent from my SM-J730GM using Tapatalk

#### gps

##### INTP 5w4 Iconoclast
Pursuant to my personal goal of embedding R source code in an org-mode file -- trivial cases at first -- then implementing parts of Seracs R code published via the Coding thread I'm starting off by launching emacs via shell commands basic enough to work with sh, dash, bash, csh, zsh, and probably a few others.

Code:
emacs --quick --execute '(eshell)'`
When executed vis my Linx Mint session emacs is launched quickly then the portable emacs shell is launched.
Emacs remains open and in with the eshell buffer active until using C-c C-c or a pull-down menu to close emacs and return to the shell from which it was launched.