Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issues commands on the command line from within a perl script

Status
Not open for further replies.

jewel464g

Technical User
Jul 18, 2001
198
US
I have used this syntax for several programs and it has always worked.

'cd /home';

but I'm writing a new program and perl give me an error
Useless use of a constant in void context at mailscript.pl line 12

I'm assuming that it's saying that because it doesn't like my syntax, is there another way to do this that I'm not aware of, or does anyone know why it is giving me this error.

Jewel When faced with a decision, always ask, 'Which would be the most fun?'
 
Perhaps you meant to use backticks ` instead of single quotes ' ?

This is normally used to capture output from the command like:

@files = `dir`; # gets dir output

MattMcGinnis
 
hehe, pardon my blonde moment, you are exactly right I did mean for those to be tick marks :}

Thanks,
Jewel When faced with a decision, always ask, 'Which would be the most fun?'
 
Hi

I am recently facing a strange problem while trying to execute a dos command in my perl script. For example
if I want to copy a file from a soure to a desitnation, it cant find that file. Eg.


$test=`copy C:\project\test\saves\output.txt D:\project\test\`;
print "$test\n";
#c:\project\term\test1.pl#

After executing the script, it gives me the print out at STDOUT as
"The system cannot find the indicated file"

But, when i use the dos command in a command window, the copy command executes.
i even try writing like
system(`copy C:\project\test\saves\output.txt D:\project\test\`);
...

But the msg is same along with some number like 256 is printed on STDOUT.

I dont understand the reason. The file name and paths are also correct.
I will be grateful, if any1 can give me a solution of this weired problem.
Thanks.

Ejaj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top