BEGIN{
getline
print $0
}
will echo whatever single line is typed on the keyboard to the STDOUT stream. Since STDOUT can be redirected and the script can easily be collapsed into a single line, we can make that echoing of the keyboard a one-liner:
gawk "BEGIN{getline;print $0}"
that can be used in a batch file to do things like get program names, file names, user names, ... whatever. See Multilingual Batch Programs for information about obtaining the free GAWK language and dealing with its documentation. @echo off
echo Enter the string to be placed into the environment.
gawk "BEGIN{getline;print \"set string=\"$0}" > }{.bat
call }{
del }{.bat
Note that additional text has been added in front of the typed string and the necessary quotes have been escaped with backslashes. That program leaves whatever string was typed in the STRING environment variable. @echo off
echo Enter the name of the program to run.
gawk "BEGIN{getline;print "$0}" > }{.bat
call }{
del }{.bat
** Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001 Ted Davis - see License, included by reference. **
Input and feedback from readers are welcome. NOTE: the subject of the message must contain the word "batch" for the message to get past the spam filter.
Back to the Table of Contents page
Back to my personal links page - back to my home page