Forum Moderators: coopster & phranque

Message Too Old, No Replies

Need simple Perl Script

move file Perl script

         

danponjican

3:36 pm on Jan 12, 2006 (gmt 0)

10+ Year Member



I need a simple Perl script to move a file from a Windows directory (i.e. c:\temp\plot) to another location set by a local environment variable called TCFILESYS (i.e. %TCFILESYS%). Can some one help me?

Thanks in advance!

bennymack

5:03 pm on Jan 12, 2006 (gmt 0)

10+ Year Member



I'm not sure how to do it in windows, but maybe you can hack this into something that works


perl -MFile::Copy\('mv'\) -e 'mv("c:\temp\plot",$ENV{TCFILESYS}) or die'

danponjican

5:50 pm on Jan 12, 2006 (gmt 0)

10+ Year Member



I copied that line of code into a file and called it 'move.pl'. Tried to execute it via a DOS promt and this was my result:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Temp\plot>move.pl
Backslash found where operator expected at C:\Temp\plot\move.pl line 1, near "MF
ile::Copy\"
syntax error at C:\Temp\plot\move.pl line 1, near "MFile::Copy\"
Backslash found where operator expected at C:\Temp\plot\move.pl line 1, near "'m
v'\"
(Missing operator before \?)
Execution of C:\Temp\plot\move.pl aborted due to compilation errors.

C:\Temp\plot>

coho75

5:56 pm on Jan 12, 2006 (gmt 0)

10+ Year Member



This may be a stupid question, but do you have Perl or ActivePerl installed on your Windows XP machine?

danponjican

6:01 pm on Jan 12, 2006 (gmt 0)

10+ Year Member



Active Perl

danponjican

6:37 pm on Jan 12, 2006 (gmt 0)

10+ Year Member



Thanks for the help guys but I figured it out.

This is basically what I was looking for:

$tcfilesys = $ENV{"TCFILESYS"};#Get the users tcfilesys directory from the environment
$target = C:\\TEMP\\PLOT\\FILE.PDF

move($target, $tcfilesys) ¦¦ die "FAILED!";