Solved

Redirect output to file in subdirectory

Posted on 2008-06-10
4
1,213 Views
Last Modified: 2008-06-10
I have a problem with a perl script that should redirect output to a certain file in a certain directory. The problematic line is
system "echo teststring >$testdir\\log.txt";

This is running on Windows 2000.

Changing the line to just
system "echo teststring >log.txt";
works fine, but when a subdirectory is specified, the file is never created and I don't get any output at all.

0
Comment
Question by:loveslave
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 21749487
what is in $testdir, and how was it set?
0
 
LVL 1

Author Comment

by:loveslave
ID: 21749546
Sorry, I should have said that from the beginning.
The value of $testdir doesn't seem to matter. Even if I do

system "echo teststring >Test\\log.txt";

I get the same error (no output, no file is created). In this case, Test is an existing subdirectory of the directory from where I call the perl script.

If I make the same call at a command prompt (echo teststring >Test\\log.txt) I get the desired result.
0
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 21749602
did you try
system "echo teststring >Test\\\\log.txt";
0
 
LVL 48

Expert Comment

by:Tintin
ID: 21749645
Why not just do it in Perl, eg:


open LOG, ">Test/log.txt" or die "Can not write to Test/log.txt $!\n";
print LOG "teststring\n";
close LOG;

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question