|
How to do things AI Noob vs. Pro
List biggest files Free Open Source: Swiss File Knifea command line
Depeche View
command line
free external tools,
cpp sources
articles |
sfk script [opts] file [-from=label] [parm1] [parm2] [...]
execute sfk command(s) from a script file, which can be
- an absolute filename, e.g. C:\scripts\thescript.txt
- a relative filename. in this case, the file is searched
in the current dir "." first, and then in the PATH.
parameters:
- if "-from=label" is given, the script file is searched
for a statement "label mylabel", and script execution runs
from this point until +end is reached.
- all other words after -from, or instead of from, are passed
as parameters to the script, with one exception:
a word starting with a "+" continues the sfk command chain.
if you need to pass words starting with "+" to the script,
set option -literal (disallowing further chain commands).
command chaining:
with ... +script name, text data is passed to the script.
with ... +fscript name, filenames are passed to the script.
script file syntax:
- text after // followed by one whitespace is a remark
and therefore ignored. (UNC paths starting like //mydir
should be placed into double quotes.)
- command line parameters 1 to 9 can be addressed both
by expressions %1 to %9, or $1 to $9.
- the current script filename and text data can be
retrieved by variables. for more see: sfk help var
- character # at column 1 of any line is skipped, which
allows bash-embedded scripts to have sfk statements
outcommented if necessary.
- escaped quotes \" are changed into normal quotes "
- line ends are ignored. in general, lines are combined
into one large command chain, just like typing them all
into one line of unlimited length.
- any whitespace is skipped unless surrounded by quotes "
however this may or may not apply with the following:
about quoted multi line parameters:
a command in a script like
+echo "
Help chapter 01
---------------
The quick brown fox
"
gets one large parameter spread across multiple lines,
called a quoted multi line parameter. this contains
many whitespaces at line starts, and invisible end of
line characters at line ends, which often cause commands
like echo, run or (x)replace not to work as expected.
- add option -qtrim after "sfk label labelnam" to have
whitespaces reduced automatically depending on command.
this is default since SFK 1.8.0.
sfk will auto apply one of these trimming modes:
full trim : all whitespace and eol are dropped.
-> used with most commands
parm trim : single blank is left between words.
-> used with run
auto indent: some blanks and eol are kept to keep
an indentation relative to 1st line.
-> used with echo
- add option -qraw after "sfk label labelnam" to keep
all whitespace as it is. this is no longer default
since SFK 1.8.0, and may be required with old scripts.
you may also set SFK_CONFIG=qraw
also type "sfk label" for infos.
parameter name collisions:
if your script contains commands like
+filter -form "$10.10col1 ..."
then "$1" will be misinterpreted as an input parameter
into the script. to avoid this use one of
+filter -form "$(10.10col1) ..."
or +filter -form "$$10.10col1 ..."
or disable $ as a parameter name prefix
by option -prefix. see "sfk label" for more on that.
options
-dos script file is OEM codepage encoded.
default is to assume Ansi encoding.
-verbose tell in detail which words are used from script.
-anyparms or -literal also passes words to the script
that start with "+". does not allow further
chain processing after the script command.
see also
sfk help chain command chaining overview
sfk help var about script parameters and variables
sfk label further options given after label
sfk load load text or data for chaining
setting global options for all commands within a script:
supply them directly after "sfk" of the calling command:
sfk -var script myscript.txt -from=mylabel
runs myscript.txt with sfk variable support
active in every command.
some options like -var can also be given after sfk label.
see "sfk label" for more.
for script examples, type:
sfk samp sfk - show an sfk sample script
sfk batch tmp.bat - sample script embedded in windows batch
sfk batch tmp.sh - sample script embedded in bash script
sfk samp - more about the sfk sample syntax
more in the SFK Book
the SFK Book contains a 60 page tutorial, including
long script examples with input, output and explanations.
type "sfk book" for details.
recommended use:
if you want to create an easy-to-use script on the fly,
1. create an embedded script in a batch file:
sfk batch myscript.bat
2. edit myscript.bat with any text editor.
3. run the script by typing "myscript.bat".
sfk script [opts] file [-from=label]
[parm1] [parm2] [...]
execute sfk command(s) from a script file,
which can be - an absolute filename, e.g.
C:\scripts\thescript.txt - a relative
filename. in this case, the file is
searched in the current dir "." first,
and then in the PATH.
parameters:
- if "-from=label" is given, the script
file is searched for a statement "label
mylabel", and script execution runs from
this point until +end is reached.
- all other words after -from, or instead
of from, are
passed
as parameters to the script, with one
exception: a word starting with a "+"
continues the sfk command chain. if you
need to pass words starting with "+" to
the script, set option -literal
(disallowing further chain commands).
command chaining:
with ... +script name, text data is
passed to the script.
with ... +fscript name, filenames are
passed to the script.
script file syntax:
- text after // followed by one
whitespace is a remark and therefore
ignored. (UNC paths starting like //
mydir should be placed into double
quotes.)
- command line parameters 1 to 9 can be
addressed both by expressions %1 to %9,
or $1 to $9.
- the current script filename and text
data can be retrieved by variables.
for more see: sfk help var
- character # at column 1 of any line is
skipped, which allows bash-embedded
scripts to have sfk statements
outcommented if necessary.
- escaped quotes \" are changed into
normal quotes "
- line ends are ignored. in general,
lines are combined into one large
command chain, just like typing them
all into one line of unlimited length.
- any whitespace is skipped unless
surrounded by quotes " however this
may or may not apply with the
following:
about quoted multi line parameters:
a command in a script like
+echo "
Help chapter 01
---------------
The quick brown fox
"
gets one large parameter spread across
multiple lines,
called a quoted multi line parameter.
this contains
many whitespaces at line starts, and
invisible end of line characters at line
ends, which often cause commands like
echo, run or (x)replace not to work as
expected.
- add option -qtrim after "sfk label
labelnam" to have
whitespaces reduced automatically
depending on command. this is default
since SFK 1.8.0. sfk will auto apply
one of these trimming modes:
full trim : all whitespace and eol
are dropped. -> used
with most commands
parm trim : single blank is left
between words. -> used
with run
auto indent: some blanks and eol are
kept to keep an
indentation relative to
1st line. -> used with
echo
- add option -qraw after "sfk label
labelnam" to keep
all whitespace as it is. this is no
longer default since SFK 1.8.0, and
may be required with old scripts. you
may also set SFK_CONFIG=qraw
also type "sfk label" for infos.
parameter name collisions:
if your script contains commands like
+filter -form "$10.10col1 ..."
then "$1" will be misinterpreted as an
input parameter into the script. to
avoid this use one of
+filter -form "$(10.10col1) ..."
or +filter -form "$$10.10col1 ..."
or disable $ as a parameter name prefix
by option -prefix. see "sfk label" for
more on that.
options
-dos script file is OEM codepage
encoded. default is to assume
Ansi encoding.
-verbose tell in detail which words
are used from script.
-anyparms or -literal also passes words
to the script
that start with "+". does not
allow further chain
processing after the script
command.
see also
sfk help chain command chaining
overview
sfk help var about script
parameters and variables
sfk label further options given
after label
sfk load load text or data for
chaining
setting global options for all commands
within a script:
supply them directly after "sfk" of the
calling command: sfk -var script
myscript.txt -from=mylabel
runs myscript.txt with sfk variable
support active in every command.
some options like -var can also be given
after sfk label.
see "sfk label" for more.
for script examples, type:
sfk samp sfk - show an sfk sample
script
sfk batch tmp.bat - sample script
embedded in windows
batch
sfk batch tmp.sh - sample script
embedded in bash
script
sfk samp - more about the sfk
sample syntax
more in the SFK Book
the SFK Book contains a 60 page
tutorial, including
long script examples with input, output
and explanations. type "sfk book" for
details.
recommended use:
if you want to create an easy-to-use
script on the fly, 1. create an embedded
script in a batch file:
sfk batch myscript.bat
2. edit myscript.bat with any text
editor. 3. run the script by typing
"myscript.bat".
you are viewing this page in mobile portrait mode with a limited layout. turn your device right, use a desktop browser or buy the sfk e-book for improved reading. sfk is a free open-source tool, running instantly without installation efforts. no DLL's, no registry changes - just get sfk.exe from the zip package and use it (binaries for windows, linux and mac are included).
|



