Did you know ... | Search Documentation: |
Packs (add-ons) for SWI-Prolog |
Title: | Unix to Prolog shell. |
---|---|
Rating: | Not rated. Create the first rating! |
Latest version: | 2.6 |
SHA1 sum: | f3dccfdbe21493b18b63dc6b366d7b200204462e |
Author: | Nicos Angelopoulos http://stoics.org.uk/~nicos |
Maintainer: | Nicos Angelopoulos http://stoics.org.uk/~nicos |
Packager: | Nicos Angelopoulos http://stoics.org.uk/~nicos |
Home page: | http://stoics.org.uk/~nicos/sware/upsh |
Download URL: | http://stoics.org.uk/~nicos/sware/packs/upsh/upsh-*.tgz |
No reviews. Create the first review!.
Version | SHA1 | #Downloads | URL |
---|---|---|---|
2.1 | 9cc904776b919c1033b3e9ac24a2c5a36bf1b49f | 3 | http://stoics.org.uk/~nicos/sware/packs/upsh/upsh-2.1.tgz |
2.2 | b8505f9d60ad658352cbc1efae15fd8085390cb1 | 1 | http://stoics.org.uk/~nicos/sware/packs/upsh/upsh-2.2.tgz |
2.3 | ed80d168b9939281bf0772a84e30254cc6402fb9 | 2 | http://stoics.org.uk/~nicos/sware/packs/upsh/upsh-2.3.tgz |
2.4 | 21a417c6166047e800589a08b0b98a5a1fbf48df | 5 | http://stoics.org.uk/~nicos/sware/packs/upsh/upsh-2.4.tgz |
2.5 | 3574fbd405211b77c06dee261567a42101fe0332 | 22 | http://stoics.org.uk/~nicos/sware/packs/upsh/upsh-2.5.tgz |
2.6 | f3dccfdbe21493b18b63dc6b366d7b200204462e | 3 | https://stoics.org.uk/~nicos/sware/packs/upsh/upsh-2.6.tgz |
To install within SWI-Prolog, do:
?- pack_install( upsh )
.
?- use_module(library(upsh))
.
?- upsh_make.
This will create executable state upsh in same directory as swipl. So you then run Prolog scripts from the command line:
> upsh say naku % /home/nicos/.rcpl compiled 0.00 sec, 8 clauses % /home/nicos/bin/cline_upsh/say.pl compiled 0.00 sec, 5 clauses naku
> upsh v
Upsh (2:1:0)-swi(7:5:7)
-(2017/6/3-0:34:36)
If you want to use the automatic search of command_line Prolog scripts, create the directory ~/bin/upsh_cline. Any Prolog program left there will be accessible to upsh for command_line invocation (see examples). In addition you can create file Lookup.pl in the same directory. See scripts/Lookup.pl for an example file.
This is upsh (Unix-Prolog SHell, or something like that- btw, I pronounce it, oupssss). The unix scripts in this directory will built an executable state (upsh*). This can be used for running Prolog programs from the unix command line.
There are two main ways in which the state can be used. command_line invocation, by issuing something like,
% upsh say hello world
Script invocation, by
% say_pl bye
In both cases, execution will start from <Script>/1,0 or main/1,0 one of which should be defined in source Program (this case `say.pl'). If more that one of these predicates are defined, the first one in the order given above will be executed.
See doc/upsh-manual.ps for more information.
Currently is known to work with anything later than : SWI (7.0.0)
Previous versions also ran on YAP and SICStus
The proper syntax for invoking upsh* expects a number of atoms that are taken to be upsh* options followed by a - seperator, followed by the Program to be executed and its Arguments. Thus, upsh {h,v}~ {<c>,s} {<m>,n} [b,e/1,f/1,d,p,o,r,w,a]- Program [Arguments]*
Curly brackets ({}) mean either-or. Less, and greater mean default value. [Argumentss]* means a number of arguments (possibly none). Things starting with a capital letter are place-holders, lower case starters are literals. Order is not important (apart of the placement of `-', that is).
Normally any progam arguments (Arg) of the form nice=tara, will
be translated to nice(tara)
(similarly isno
good goes to is(no(good))
).
These will be seen as terms in the call to the script. If
you use '-' and option 'o' then the isno
good is passed as picked
by current_prolog_flag( argv, AllArgs )
, (i.e. as one atom).
Every other Arg is passed as atom (including numbers, so make sure
you convert them, before using them in your program).
Sloppy syntax, is also supported. This allows for the omission of `-'. It is the default behaviour (change with 'r' option) and it means upsh* will take anything that looks like an upsh option from the command line and treats anything that it didnt use as if it appearred after a hyphen, '-'. (In this case your Args will get translated for sure because that's what happens to upsh arguments).
The following options are thought to be recognised.
portray_message( informational, _ )
lines in upsh_Prolog.pl rebuild and you can then do some
debugging from the Prolog prompt.
p : surpress loading info (of Program).
All those compiling and compiled messages.
o : donot translate, Arg. thus `verynice
tara' behind `-' will not be
translated to term very(nice(tara))
.
r : be strict about the \`-\' . Options to the left Program and it Args to
the right. Anything that is not an upsh option and appears to the
left goes to the bin. Similarly Args that could be seen as
upsh options and appear to the right of '-' will be passed to the Program.
w : wait for input at end of execution.
a : last argument holds all read variable lists (upsh_vs/1).
For scripts add the following, as the first two lines in the prolog file,
/bin/sh exec upsh s - $0 "$@"
Then, do : % chomod u+x <PlFile>
If you have problems with working in the wrong directory, try the following as a second line, instead :
exec upsh s d=pwd
- $0 "$@
Upsh, comes with two examples, say and tall which can be found in directory scripts/ . 'say' simply spews out its input arguments one at the time. tall, touches all its arguments (where `touch'; is the unix command). These come in two flavours, File.pl for running as an upsh* command_line argument, or used from within the interpreter, while File_pl is an executable script.
Some examples with these two programs, follow :
This software is not distributated, per se. It simply exists. Whether you use it or not, is your problem.
Interesting suggestions, can be send to n.angelopoulos@nki.nl
Nicos, April 2004
Made into a pack May 2016. Last update: December 2019.
Pack contains 61 files holding a total of 682K bytes.