Print in file using perl code but running it through cmd
<p>I am trying to print a text in one file using the below code:
test.pl</p>

<pre><code>#!/usr/bin/perl
use strict;
use warnings;

my $file="testing.txt";

open(INP_FILE,'&gt;&gt;',$file);
    print INP_FILE "Test\n";
close(INP_FILE);
print "Text is Printed\n";
</code></pre>

<p>While running it through cygwin, I am able to print it in file. But when running the same file through cmd using below command, it does print "Printed" on console but file is not written with 'Test' text.</p>

<pre><code>C:\Users\TD&gt;C:\cygwin64\bin\perl.exe /home/TD/GMAT/test.pl
Printed
C:\Users\TD&gt;
</code></pre>

<p>Basically I am just testing the functionality, later on I will run system command to take backup from my database. And I am trying to run this cmd through task scheduler to take automatic backup.</p>

<p>In windows task scheduler, I am opening cmd.exe and giving the argument as <code>/c C:\cygwin64\bin\perl.exe /home/TD/GMAT/test.pl</code></p>

<p>This command is closing the window after running the script and I am not able to check the output from cmd console but printing the file in cygwin console. </p>

<p><strong>Let me know if there is any other method to automate the process of running the perl script through task scheduler</strong></p>