[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Redirect output to file in subdirectory

Posted on 2008-06-10
4
Medium Priority
?
1,219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Six Sigma Control Plans

649 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