Re: How Do I Get Batch Input to Work in DOS?
by BrowserUk (Patriarch) on Mar 01, 2012 at 02:49 UTC
|
I tried 'myfile.pl < pl_input.txt' .... But it doesn't work ...
Works fine for me:
C:\test>junk.pl < junk.pl
>< elihw _$ esrever ralacs tnirp
C:\test>
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
| [reply] [d/l] |
|
The fact it works for you makes me wonder what configuration settings or other special constructs might be needed for this to work on my computer.
Are there any environment variables that might need tweaking? Or anything to put in the script file?
tnx,
jmk
| [reply] |
|
Are there any environment variables that might need tweaking? Or anything to put in the script file?
How about you provide a little more information:
- What version of perl are you using?
perl -v
- What version of "DOS" are you using?
ver
- What file associations do you have?
assoc .pl
The above produce output like: .pl=xxxx. Substitute whatever you get instead of 'xxxx' into the following command:
ftype xxxx
- The output from the following two commands:
set pat
set per
- Your full runnable code.
Or if it is huge or proprietary; a complete, self-contained, runnable script that demonstrates the problem.
- A cut&paste of the console log showing the posted code being run on your system.
If you supply that information, we here will almost certainly be able to solve your problem. Without it, all we can do is guess, usually wrongly.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
| [reply] [d/l] [select] |
|
|
|
|
|
Re: How Do I Get Batch Input to Work in DOS?
by Corion (Patriarch) on Mar 01, 2012 at 08:48 UTC
|
| [reply] [d/l] |
Re: How Do I Get Batch Input to Work in DOS?
by ww (Archbishop) on Mar 01, 2012 at 02:38 UTC
|
How about writing a routine into your myfile.pl to read input.txt into an array, and then feeding the (input) elements as needed/where needed?
But heed Riales: this would be better advice (less of a WAG) were you to post some code showing what's at issue. You'll do better, also, if you tell us something more specific than "doesn't work as expected." That could mean anything from 'no visible response' to 'my computer starts spitting out $20 gold pieces.' | [reply] [d/l] [select] |
Re: How Do I Get Batch Input to Work in DOS?
by Riales (Hermit) on Mar 01, 2012 at 01:57 UTC
|
I'm not familiar with DOS, but I would think you need to actually print the contents of pl_input.txt to STDOUT before piping it into your program. This is how I would do it in bash:
$ cat pl_input.txt | myfile.pl
EDIT: Nevermind, I did some research and it looks like what you were doing should be fine. Maybe post your code/input file so we have some more to go on? What's happening that's unexpected? | [reply] [d/l] |
|
Thanks for the response. Here are some more details -
The script is a format checker (aka linter) for script input - to ensure against typos. You provide the directory where the files are located, indicate the exam you want performed and the script generates a report of any errors found. If you want to retest- well, an input file of commands would be helpful, thus my question.
Here's the code snippet that receives the input.
if( $runnum < 1) {
$cwd = Win32::GetCwd();
$prgmdir = $cwd;
# $prgmpth = "$prgmdir\\";
print "\nProgram thinks it is located in the following directo
+ry:\n";
print "\t$cwd\n";
print "if incorrect (PATH has spaces)! Enter full path or ret
+urn\n\n";
chomp ($prgmd = <STDIN>);
if( $prgmd =~ /^([a-zA-Z];\\).+$/ ) {
$prgmdir = $prgmd;
}
else {
$prgmdir = $cwd;
}
$prgmdir =~ /^(\w:).*/;
$prgmdrv = $1 . ":";
}
When I run the script, I get the above query which seems to get some input (but nothing obvious on screen) where it next goes to the menu containing the "exit" command and then goes to the dos prompt as if it concluded.
A check of the output directory indicates no activity.
I expected to see some material to the screen and/or results in the work directory - but this is not the case, thus the question on what it would take to get it to work.
jmk | [reply] [d/l] |
|
When you run your script, do you get those lines about where the program thinks it is and if it's incorrect to enter the full path or return? Have you tried adding a print after you assign to $prgmdrv to see what it's doing at that point? (Standard 'print statements everywhere!' advice, but still...)
I wonder if it might make more sense to modify the original script to optionally take an input file of commands instead of trying to pipe the commands in externally?
| [reply] [d/l] |
Re: How Do I Get Batch Input to Work in DOS?
by jmk2012 (Initiate) on Mar 01, 2012 at 20:07 UTC
|
Thanks for the response. Here are some more details - The script is a format checker (aka linter) for script input - to ensure against typos. You provide the directory where the files are located, indicate the exam you want performed and the script generates a report of any errors found. If you want to retest- well, an input file of commands would be helpful, thus my question. Here's the code snippet that receives the input.
if( $runnum < 1) {
$cwd = Win32::GetCwd();
$prgmdir = $cwd;
# $prgmpth = "$prgmdir\\";
print "\nProgram thinks it is located in the following directo
+ry:\n";
print "\t$cwd\n";
print "if incorrect (PATH has spaces)! Enter full path or ret
+urn\n\n";
chomp ($prgmd = <STDIN>);
if( $prgmd =~ /^([a-zA-Z];\\).+$/ ) {
$prgmdir = $prgmd;
}
else {
$prgmdir = $cwd;
}
$prgmdir =~ /^(\w:).*/;
$prgmdrv = $1 . ":";
}
download
When I run the script, I get the above query which seems to get some input (but nothing obvious on screen) where it next goes to the menu containing the "exit" command and then goes to the dos prompt as if it concluded. A check of the output directory indicates no activity. I expected to see some material to the screen and/or results in the work directory - but this is not the case, thus the question on what it would take to get it to work. jmk | [reply] [d/l] |