Solved

Redirect output to file in subdirectory

Posted on 2008-06-10
4
1,211 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

809 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