## Shell command fails in LC

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

thatkeith
VIP Livecode Opensource Backer
Posts: 170
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK

### Re: Shell command fails in LC

@hh,
Useful summaries, thanks!
A few points specific to what I'm doing:
• The final tool must work on Mac. If it works on Windows/Linux that's great, but that would be for broader distribution. The primary need is to run on some of the Macs here at university, some in rooms where I teach (reason: to help my students learn about and prepare print projects) and some in the open-access digital print facilities (reason: to reduce the headaches my colleagues there have with poorly-made student PDFs). Solving cross-platform complexities is a good aim but it should be a stage 2 thing.
• Getting admin-level installations done on most of these Macs would be, ah, 'rather difficult'... they're centrally managed, and while the 'local' IT department is very favourably inclined to me and my shenanigans, the central team is much more of the 'not invented here' mindset. (For a tool distributed more publicly that's fine, but that too is more of a second-stage goal.) Hence me wanting to internalise or localise the *TeX 'installation' as something that is used entirely on the fly. Which leads me to...
@Thierry,
You said "installed properly" and "as long as the $PATH has been updated during installation." What I'm trying to figure out is can something like this be 'installed' by (a) having it available in a logical place (even, dare I think it, inside an app package?), and (b) setting up$PATH appropriately – even if it's just for the duration and use of the shell that does that?

k
Senior Lecturer, LCC (University of the Arts London)
Technical Editor, MacUser (1996-2015)
President, IVRPA.org

Thierry
VIP Livecode Opensource Backer
Posts: 580
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

### Re: Shell command fails in LC

Getting admin-level installations done on most of these Macs would be, ah, 'rather difficult'...
Ok, may I ask you a question before going further?

I did look at the installation package of BasicTeX and the only option we have is
"Install for every users of this computer" which means we have to give the system password sooner or later
during the installation.

How are you going to deal with that, if possible?

I didn't see anything ( but I've read everything fast) which permits to install on a user's home directory...

It might be a show stopper for this project, no?

Regards,

Thierry
Thierry Douez - https://sunny-tdz.com
Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara]

thatkeith
VIP Livecode Opensource Backer
Posts: 170
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK

### Re: Shell command fails in LC

That could indeed be a show-stopper. Actually, it might not be that bad in the long run as I can probably argue successfully that it should eventually be installed on *some* machines in order to support the tool I'm making. But it would certainly limit distribution quite a bit; admin authentication is not something used casually on those Macs.

Yes, the installer is an 'all users' one, but might that be just because that's the overwhelmingly logical way to go for (almost) every possible use of something this powerful... and not because it *has* to run like that? I'll try making an utterly minor change to its location (such as put it in a new dir where it currently lives), tell $PATH about this, and see if I can still have it invoked. Baby steps. Because that's my level here. k Senior Lecturer, LCC (University of the Arts London) Technical Editor, MacUser (1996-2015) President, IVRPA.org Thierry VIP Livecode Opensource Backer Posts: 580 Joined: Wed Nov 22, 2006 3:42 pm Location: France Contact: ### Re: Shell command fails in LC Hi Keith, I found this: Alternate Installation Procedures MacTeX installs TeX Live in /usr/local/texlive, a location requiring root access. Some users do not have access to this location. They can still obtain TeX Live by using the TeX Live Install Script, which can install in any location. Details are provided below: The TeX Live Install Script can be obtained at http://www.tug.org/texlive/acquire-netinstall.html. The script is a small file which is run from Terminal. It asks a series of questions, and then downloads and installs TeX Live piece by piece over the internet. Follow the suggestions below if you want your installation to behave like MacTeX's install of TeX Live. I guess we could hack this Install Script to automate the process via LiveCode... Regards, Thierry Thierry Douez - https://sunny-tdz.com Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara] Thierry VIP Livecode Opensource Backer Posts: 580 Joined: Wed Nov 22, 2006 3:42 pm Location: France Contact: ### Re: Shell command fails in LC thatkeith wrote: I'll try making an utterly minor change to its location (such as put it in a new dir where it currently lives), tell$PATH about this, and see if I can still have it invoked.
Mmm, either you will gifted by some Gods or you'll have the worst nightmares of your life...

I won't follow you on this track; I'm too old for that

Kind regards,

Thierry
Thierry Douez - https://sunny-tdz.com
Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara]

[-hh]
VIP Livecode Opensource Backer
Posts: 1538
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: Shell command fails in LC

My TeX stack came upwards in my toDo list (though it is still after some LCB and HTML5 things).
Anyway: Here is a first step for completion. This is for Mac only, because Keith needs that just now, others OS require only slightly different instructions.

Instruction for a "portable" TeX-installation
(basic up to full installation is possible)

(Note. This may still run extremely fast if you run it from an external HD/SSD, but may slow down if you run it from an 8 GByte USB 2.0 stick).

Needs an internet connection. Description if running on a Mac OS 10.6 or later.
The description is idiot proof, may be also academic proof (I'm also academic).
• [0. ] Mount your USB-stick or extern HD/SSD,
say it has the name "T" <-- adjust here and in (5c).
• [1a.] go to http://www.tug.org/texlive/acquire-netinstall.html and
• [1b.] Unpack it (doubleClick in Finder)
• [1c.] Open the folder and doubleClick "install-tl", a terminal window opens, wait ...
• [2. ] Enter "n" to the question for import settings.
• [3. ] (Optionally enter "b" and choose other platforms.)
• [4. ] Enter "v" to choose a portable installation.
• [5a.] Enter "d" to choose a directory target for the portable
• [5b.] Enter "1".
• [5c.] Enter "/Volumes/T/texliveBasic2017" (directory will be created for you)
• [6a.] Enter "s" to choose a scheme.
• [6b.] Enter "c" (=small, 446 MByte) or "d" (=basic, 160 MByte)
• [7a.] Check again all listed settings.
• [7b.] Enter "i" to start the installation.
• [8a.] Watch the installation which runs dependent on your connection speed more or less fast.
• [8b.] Memorize the last output lines (which are here)
Most importantly, add /Volumes/T/texliveBasic2017/bin/x86_64-darwin to your PATH for current and future sessions.
• [8c.] Enjoy.
Now put your pdf helpers also into /Volumes/T/texliveBasic2017, so that you have the same PATH.
Then you can simply copy the installation to other media (which have the same name "T")

IMPORTANT: Avoid spaces in filenames or paths.
TeX hates spaces in names. Spaces are reserved for multiple arguments.

Test it:

Say you have a document "/Volumes/T/mytex/letterBixby.tex"
You can test the installaton as follows.

Make a new stack: Add a button and a browser widget (for viewing the pdf).
Script the button as follows.

Code: Select all

local baseaddress="/Volumes/T/mytex/", bb="Browser"

function texPraefix
return "PATH=/Volumes/T/texliveBasic2017/bin/x86_64-darwin:$PATH; export PATH" &cr& \ "MANPATH=/Volumes/T/texliveBasic2017/texmf-dist/doc/man:$MANPATH; export MANPATH" &cr& \
"INFOPATH=/Volumes/T/texliveBasic2017/texmf-dist/doc/info:$INFOPATH; export INFOPATH" &cr end texPraefix on mouseUp set the shellcommand to "/bin/bash" set the defaultfolder to baseaddress -- the folder where "letterBixby.tex" resides put texPraefix() into texit -- texit ends with cr put shell(texit & "pdflatex -interaction nonstopmode letterBixby") -- may be more is needed for a slow usb stick, better: put this last -- part into an extra button. so user can push when the log says OK. Also: -- Some latex docs need two runs (for citations etc.) before the PDF is OK put baseaddress & "letterBixby.pdf" into tPDF wait 500 millisecs with messages set URL of widget bb to tPDF end mouseUp  Here are the input (letterBixby.tex) and output (letterBixby.pdf) file, the URL in the generated pdf is clickable. Thanks to Keith and Thierry for their valuable discussion and hints. Edit: Just tested for selecting several different OS in step (3): linux 32bit, linux armhf, win32, mac 64bit. It works fine. The installer adds for each OS an own binary folder to the portable bin-folder. Non-binary files are shared between the four. So you have only to get the platform with LiveCode and switch PATH accordingly to the platform's subfolder of the portable bin folder. The portable size increases for these 4 OSes to less than twice the single OS installation. Attachments letterBixby.tex.zip (1.27 KiB) Downloaded 32 times letterBixby.pdf.zip (33.08 KiB) Downloaded 31 times Last edited by [-hh] on Wed Jul 19, 2017 10:35 am, edited 1 time in total. shiftLock happens Thierry VIP Livecode Opensource Backer Posts: 580 Joined: Wed Nov 22, 2006 3:42 pm Location: France Contact: ### Re: Shell command fails in LC Excellent Hermann ! I'm sure Keith will find his way by now... Enjoy your day, Thierry Thierry Douez - https://sunny-tdz.com Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara] [-hh] VIP Livecode Opensource Backer Posts: 1538 Joined: Thu Feb 28, 2013 11:52 pm Location: Göttingen, DE ### Re: Shell command fails in LC @Thierry Thanks for the flowers, I'll give more than the half back to you. @Keith If you select variant "c" in step (6b) of the instructions above you have also the full XeTeX and can output such beautiful things like the attachment below. Preview is a jpg, download the zipped pdf for seeing the full beauty of Hermann Hesse's "Steps" and Hermann Zapf's font "Zapfino". Attachments steps.pdf.zip The pdf, resize to screensize. (17.98 KiB) Downloaded 36 times Preview, click to zoom it shiftLock happens thatkeith VIP Livecode Opensource Backer Posts: 170 Joined: Mon Mar 01, 2010 7:13 pm Location: London, UK ### Re: Shell command fails in LC Thierry wrote:Mmm, either you will gifted by some Gods or you'll have the worst nightmares of your life... Well, this is a 'sacrificial' Mac; I have a second laptop, temporarily, that I can wipe and set up and wipe again if necessary. It's a luxury I'm prepared to exploit in the pursuit of learning while I have it! k Senior Lecturer, LCC (University of the Arts London) Technical Editor, MacUser (1996-2015) President, IVRPA.org thatkeith VIP Livecode Opensource Backer Posts: 170 Joined: Mon Mar 01, 2010 7:13 pm Location: London, UK ### Re: Shell command fails in LC [-hh] wrote:the full beauty of Hermann Hesse's "Steps" and Hermann Zapf's font "Zapfino". Zapfino is extraordinary, isn't it? Thanks for this! In return, you may enjoy reading a column of mine on the origins and uses of Zapfino: http://www.thisbloglife.com/2017/02/652/ (I was MacUser magazine's Technical Editor from the mid-90s to its close in 2015, and from around 2008 I had the privilege of writing a column on design in every issue. It gave me license to explore this kind of thing to my heart's content!) k Senior Lecturer, LCC (University of the Arts London) Technical Editor, MacUser (1996-2015) President, IVRPA.org [-hh] VIP Livecode Opensource Backer Posts: 1538 Joined: Thu Feb 28, 2013 11:52 pm Location: Göttingen, DE ### Re: Shell command fails in LC How can you write such an (yes, wonderful) article without mentioning TeX? I'm deeply disappointed. No other system is able to typeset Zapfino in such a perfect way. See the simple input needed for that below. We know both, that TeX was created by D. Knuth. That's why its core alone is still the best typesetting engine on earth, 40 years after the first version was written. Also complicated math/biological/chemical/physical expressions need design. They have their own poesy. Knuth created the art of typesetting (important) things in a beautiful way. Content of file "steps.tex" that is the input for the XeTeX-output "steps.pdf" above. Code: Select all %!TEX TS-program = xetex %!TEX encoding = UTF-8 Unicode %%============================= \pdfpageheight=20cm \pdfpagewidth=20cm \hoffset=-.5in \voffset=-.5in %%============================= % special characters converted to Unicode % and Zapfino font declarations %%%%%%% % Acknowledgement: Example is essentially authored by Jonathan Kew %%%%%%% \font\bodyfont="Zapfino" at 8pt \font\titlefont="Zapfino:Stylistic Variants=First variant glyph set" at 10pt \font\authorfont="Zapfino:Stylistic Variants=Second variant glyph set" at 8pt \def\startcentering{\par\begingroup \leftskip=0pt plus 1fil \rightskip=\leftskip \parindent=0pt \parfillskip=0pt } \def\endcentering{\par\endgroup} %%============================= \nopagenumbers \bodyfont \hrule \vskip 16mm \centerline{\titlefont STEPS \ ( STUFEN )} \vskip 2mm \centerline{\authorfont by Hermann Hesse} \vskip 5mm \obeylines \startcentering \advance\parskip2pt As every blossom fades and all youth sinks into old age, so every life’s design, each flower of wisdom, attains its prime and cannot last forever. The heart must submit itself courageously to life’s call without a hint of grief, A magic dwells in each beginning, protecting us, telling us how to live. High purposed we shall traverse realm on realm, cleaving to none as to a home, the world of spirit wishes not to fetter us but raise us higher, step by step. Scarce in some safe accustomed sphere of life have we establish a house, then we grow lax; only he who is ready to journey forth can throw old habits off. Maybe death’s hour too will send us out new-born towards undreamed-lands, maybe life’s call to us will never find an end. Courage my heart, take leave and fare thee well. \endcentering \vskip 16mm \hrule \bye shiftLock happens thatkeith VIP Livecode Opensource Backer Posts: 170 Joined: Mon Mar 01, 2010 7:13 pm Location: London, UK ### Re: Shell command fails in LC [-hh] wrote:How can you write such an (yes, wonderful) article without mentioning TeX? Hah! Thanks for the compliment. There were two reasons why I didn't mention TeX: One: MacUser was aimed at designers who typically go no further than HTML when it comes to code, and when typesetting is mentioned would automatically open InDesign or QuarkXPress. We always had readers who were awesomely proficient in many different digital languages from PHP to C, but they weren't the core focus of the mag. However, the reason I didn't mention it in my column, where I had carte blanche in what I wrote, was... Two: I was even more ignorant about TeX then than I am now! Mea culpa. k Senior Lecturer, LCC (University of the Arts London) Technical Editor, MacUser (1996-2015) President, IVRPA.org [-hh] VIP Livecode Opensource Backer Posts: 1538 Joined: Thu Feb 28, 2013 11:52 pm Location: Göttingen, DE ### Re: Shell command fails in LC I understand, of course. So finally is here an input file (and an output for comparing) that typesets your "cited" Hans-von-Weber text. The typeset is dedicated to you — the content is probably not your full opinion, may be even not "beautiful": The Times They Are A-Changin' ... Code: Select all %!TEX TS-program = xetex %!TEX encoding = UTF-8 Unicode %%============================= \pdfpageheight=20cm \pdfpagewidth=20cm \hoffset=-.5in \voffset=-.5in %%============================= % special characters converted to Unicode % and Zapfino font declarations % Example essentially by J. Kew (the author of XeTeX) \font\zapfino="Zapfino:Stylistic Variants=Second variant glyph set" at 10pt \def\startcentering{\par\begingroup \leftskip=0pt plus 1fil \rightskip=\leftskip \parindent=0pt \parfillskip=0pt } \def\endcentering{\par\endgroup} %%============================= \nopagenumbers \zapfino \hrule \vskip 12mm \obeylines \startcentering \advance\parskip1pt Wie kann man bei der Wahl schwanken, ob man sein Leben den Frauen oder den Büchern weihen soll! Kann man eine Frau, wenn sie ihre Launen hat, zuklappen und ins Regal stellen? Wanderte schon einmal ein Buch, ohne dich zu fragen, einfach aus deinem Zimmer weg in den Bücherschrank eines anderen? Hat je ein Buch, stand dir gerade die Lust zu einem anderen, wolltest du schlafen oder auch nichts tun, von dir verlangt, du solltest gerade jetzt es lesen und ihm allein dich widmen? Werden die Suppen von Büchern versalzen? Können Bücher schmollen, Klavier spielen? Einen Mangel freilich haben sie: sie können nicht küssen! \vskip 3mm\hfil\hskip50mm Hans von Weber \endcentering \vskip 12mm \hrule \bye To call it with my script above if you have an installation that includes XeteX (BasicTex has this also) use the two changed lines: Code: Select all  put shell(texit & "xetex -interaction nonstopmode weber") put baseaddress & "weber.pdf" into tPDF  Attachments weber.pdf.zip The output pdf by XeTeX of the input above Second variant glyph set (13.55 KiB) Downloaded 30 times Preview, click to enlarge shiftLock happens Thierry VIP Livecode Opensource Backer Posts: 580 Joined: Wed Nov 22, 2006 3:42 pm Location: France Contact: ### Re: Shell command fails in LC playing a couple of hours with LiveCode and the shell() function, I end up with this one-press-button TeX portable basic installation: and in the "test TeX" button: Code: Select all on mouseUp put shell( "tex -v") end mouseUp TeX 3.14159265 (TeX Live 2017) kpathsea version 6.2.3 Copyright 2017 D.E. Knuth. There is NO warranty. Redistribution of this software is covered by the terms of both the TeX copyright and the Lesser GNU General Public License. For more information about these matters, see the file named COPYING and the TeX source. Primary author of TeX: D.E. Knuth. All the process runs in less than a minute! Next to come tomorrow... Regards, Thierry Thierry Douez - https://sunny-tdz.com Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara] Thierry VIP Livecode Opensource Backer Posts: 580 Joined: Wed Nov 22, 2006 3:42 pm Location: France Contact: ### Re: Shell command fails in LC Hi Keith, and here is the results of my latest tests: my former installation of a portable TeX in a *normal* defined folder (not a USB nor CD/DVD) works. Now, I"m moving the whole TeX folder to another place, edit the$PATH env variable, and run again the compil of a Tex document,
and it still works!

Code: Select all

   put shell("pdflatex lettex.tex")
CQFD!

To recap, it's possible to install a TeX basic 2017 tools in a specific folder,
changing the PATH accordingly (see one of my former post) and you can run
any pdflatex commands you like.

Then, move the TeX folder wherever you want,
more importantly on another Mac,
edit the PATH and run again your TeX commands.

If you are interested by the installation scripts,
just ask and I'll send it to you after a bit of cleaning.

HTH,

Thierry
Thierry Douez - https://sunny-tdz.com
Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara]