Hi,
I have a code snippet like:
<<CUT>>
@args = "/bin/vi /tmp/t1.txt";
$val = system(@args);
if($val != 0) {
 if($val == -1) {
    print "Execution failed  $OS_ERROR\n";
    exit;
 } else {
    print "Program exited with error code $? << 8\n";
    exit;
 }
}

Notice that the code snippet is executing vi with a file and hence editor opens up the file. After typing if I give a wrong vi command for eg: "W" instead of "w"; $val gets a value greater than zero(256) and hence the else part gets executed. The number of times I give a wrong vi command , the return value gets incremented by 256.
This snippet is part of a larger program, which opens a editor and asks the user to type in, after the user saves the file contents and exits out of the editor, the program reads the contents of the file for further processing.


Is there a way to overcome this situation?

Thanks in advance
Prasanna







--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to