Sign in to follow this  
Followers 0
Paradox

Why can't I copy?

2 posts in this topic

Okay, before you see the code, look for the msgbox() line in sections 4 & 5. It's only there for my own reference just to show myself that it IS looking for the EXACT CORRECT UNC path and file name.

when the script gets to the line immediately after it, the one that is supposed to copy the file itself, I get a message saying "Error: Unable to execute the external program. The system cannot find the file specified". I know this is a bunch of crap because if I type in the EXACT SAME copy command that I have the $copy variable set to (from a cmd prompt) it copies with no questions... (yes, I tried "filecopy(@comspec & $copy) but I get basically the same message).

That being said, here's the full code. Thanks guys!

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        Jason Fritzsche <jfritzs@docubase.net>
;
; Script Function:
;   1. Shut down services on remote server.
;   2. Discover modified mini-disks on main server by doing a comparison of the .SIM files
;   3. Send file to main server with name of mini-disk(s) to be compressed for transmission.
;   4. wait for confirmation file from main server that mini-disk(s) have been compressed.
;   5. copy compressed file from server
;   6. uncompress transferred files to WORM location
;   7. Copy .SIM file and all insuranc.dbb\insurance.* files to relative locations on local machine.
;   8. restart services
;
; ----------------------------------------------------------------------------

#cs
    Database syncronization v0.1
    1/12/06
#CE

#include <file.au3>
#include <array.au3>

fileinstall("d:\dbinstall\rar.exe", @Scriptdir & "\rar.exe", 0)

; declaration of variables
    global $dbstart, $dbstop, $confirm, $files2compress, $simLocal, $simRemote, $aSim, $aSimRemote, $minidisk, $last, $minidiskRemote

    $dbstart="net start ""docubase service"""
    $dbstop="net stop ""docubase service"""
    $confirm="copydone.txt"
    $simLocal="insuranc.sim"
    $simRemote="\\dmay\DbBases\insuranc.sim"
    
; 1. Shut down services

    runwait($dbstop)

; 2 & 3. Compare sim files and create file (files2compress.txt) on remote machine containing names and
;   locations of minidisks to compress for transmission. :)

    dim $minidiskRemote[4096]
    
    $amountoflocallines=_filecountlines($simLocal)
    $amountofremotelines=_filecountlines($simRemote)

;msgbox(0, "Totals", "Total amount of lines in Local copy: " & $amountoflocallines & " Amount of remote lines: " & $amountofremotelines & ".")

    $files2compress = fileopen("\\dmay\dbbases\files2compress.txt", 2)
    
    if ($amountoflocallines==$amountofremotelines) and ($amountofremotelines <= 2) then
        for $x = 1 to $amountofremotelines
            $minidiskRemote[$x] = filereadline($simRemote, $x)
            $minidiskremote[$x] = stringtrimleft($minidiskremote[$x], 1)
            $minidiskremote[$x] = stringtrimright($minidiskremote[$x], 1)
            filewriteline($files2compress, $minidiskremote[$x])
        next

    elseif ($amountofremotelines > $amountoflocallines) and ($amountofremotelines <= 2) then
        for $x = ($amountofremotelines-1) to $amountofremotelines
            $minidiskRemote[$x] = filereadline($simRemote, $x)
            $minidiskremote[$x] = stringtrimleft($minidiskremote[$x], 1)
            $minidiskremote[$x] = stringtrimright($minidiskremote[$x], 1)
            filewriteline($files2compress, $minidiskremote[$x])
        next

    elseif ($amountofremotelines == $amountoflocallines) and ($amountofremotelines > 2) then
        for $x = ($amountofremotelines-1) to $amountofremotelines
            $minidiskRemote[$x] = filereadline($simRemote, $x)
            $minidiskremote[$x] = stringtrimleft($minidiskremote[$x], 1)
            $minidiskremote[$x] = stringtrimright($minidiskremote[$x], 1)
            filewriteline($files2compress, $minidiskremote[$x])
        next
    
    elseif ($amountofremotelines > $amountoflocallines) then
        for $x = ($amountofremotelines-2) to $amountofremotelines
            $minidiskRemote[$x] = filereadline($simRemote, $x)
            $minidiskremote[$x] = stringtrimleft($minidiskremote[$x], 1)
            $minidiskremote[$x] = stringtrimright($minidiskremote[$x], 1)
            filewriteline($files2compress, $minidiskremote[$x])
        next
    endif
    fileclose($files2compress)  
    
; 4 & 5. Wait for confirmation (compresscomplete.txt) from main server. 
;   File will have name of file to transfer. File will then be copied to local machine into the 
;   scripts directory.


    $compresscomplete="compresscomplete.txt"

        while fileexists($compresscomplete)=0
            sleep(30000)
        wend
    
    $file=fileopen($compresscomplete, 0)
    
    $file2transfer=filereadline($file)
    
    fileclose($file)
    
    filedelete($file)
    
    $copy="copy " & $file2transfer & " " & @Scriptdir & "\"

    msgbox(0, "test", "Path to copy = " & $copy)
    runwait($copy)

; 6. Uncompress transferred file.

    $rar=@Scriptdir & "\rar.exe x " & @Scriptdir & "\compressed.rar -o+ -inull " & @Scriptdir & "\insurance.dbb\worm\"
    RUNwait($rar)

; 7. Copy .SIM file from main system, overwriting the original located on this machine. 
;   Rather than reindex, we're also going to just do a direct copy of the index files
;   (.DAT, .DC2, .DCS, .ND2, .NDS, .RL2, .RLS, .STO)
    
    $copy="copy " & $simRemote & " " & @scriptdir & "\ /Y"
    runwait($copy)
    $copy="copy \\dmay\dbbases\insuranc.dbb\insuranc.* " & @scriptdir & "\insurance.dbb\ /Y"
    runwait($copy)

; 8. Restart Docubase services.

    runwait($dbstart)

exit

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Okay, before you see the code, look for the msgbox() line in sections 4 & 5. It's only there for my own reference just to show myself that it IS looking for the EXACT CORRECT UNC path and file name.

when the script gets to the line immediately after it, the one that is supposed to copy the file itself, I get a message saying "Error: Unable to execute the external program. The system cannot find the file specified". I know this is a bunch of crap because if I type in the EXACT SAME copy command that I have the $copy variable set to (from a cmd prompt) it copies with no questions... (yes, I tried "filecopy(@comspec & $copy) but I get basically the same message).

That being said, here's the full code. Thanks guys!

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        Jason Fritzsche <jfritzs@docubase.net>
;
; Script Function:
;   1. Shut down services on remote server.
;   2. Discover modified mini-disks on main server by doing a comparison of the .SIM files
;   3. Send file to main server with name of mini-disk(s) to be compressed for transmission.
;   4. wait for confirmation file from main server that mini-disk(s) have been compressed.
;   5. copy compressed file from server
;   6. uncompress transferred files to WORM location
;   7. Copy .SIM file and all insuranc.dbb\insurance.* files to relative locations on local machine.
;   8. restart services
;
; ----------------------------------------------------------------------------

#cs
    Database syncronization v0.1
    1/12/06
#CE

#include <file.au3>
#include <array.au3>

fileinstall("d:\dbinstall\rar.exe", @Scriptdir & "\rar.exe", 0)

; declaration of variables
    global $dbstart, $dbstop, $confirm, $files2compress, $simLocal, $simRemote, $aSim, $aSimRemote, $minidisk, $last, $minidiskRemote

    $dbstart="net start ""docubase service"""
    $dbstop="net stop ""docubase service"""
    $confirm="copydone.txt"
    $simLocal="insuranc.sim"
    $simRemote="\\dmay\DbBases\insuranc.sim"
    
; 1. Shut down services

    runwait($dbstop)

; 2 & 3. Compare sim files and create file (files2compress.txt) on remote machine containing names and
;   locations of minidisks to compress for transmission. :)

    dim $minidiskRemote[4096]
    
    $amountoflocallines=_filecountlines($simLocal)
    $amountofremotelines=_filecountlines($simRemote)

;msgbox(0, "Totals", "Total amount of lines in Local copy: " & $amountoflocallines & " Amount of remote lines: " & $amountofremotelines & ".")

    $files2compress = fileopen("\\dmay\dbbases\files2compress.txt", 2)
    
    if ($amountoflocallines==$amountofremotelines) and ($amountofremotelines <= 2) then
        for $x = 1 to $amountofremotelines
            $minidiskRemote[$x] = filereadline($simRemote, $x)
            $minidiskremote[$x] = stringtrimleft($minidiskremote[$x], 1)
            $minidiskremote[$x] = stringtrimright($minidiskremote[$x], 1)
            filewriteline($files2compress, $minidiskremote[$x])
        next

    elseif ($amountofremotelines > $amountoflocallines) and ($amountofremotelines <= 2) then
        for $x = ($amountofremotelines-1) to $amountofremotelines
            $minidiskRemote[$x] = filereadline($simRemote, $x)
            $minidiskremote[$x] = stringtrimleft($minidiskremote[$x], 1)
            $minidiskremote[$x] = stringtrimright($minidiskremote[$x], 1)
            filewriteline($files2compress, $minidiskremote[$x])
        next

    elseif ($amountofremotelines == $amountoflocallines) and ($amountofremotelines > 2) then
        for $x = ($amountofremotelines-1) to $amountofremotelines
            $minidiskRemote[$x] = filereadline($simRemote, $x)
            $minidiskremote[$x] = stringtrimleft($minidiskremote[$x], 1)
            $minidiskremote[$x] = stringtrimright($minidiskremote[$x], 1)
            filewriteline($files2compress, $minidiskremote[$x])
        next
    
    elseif ($amountofremotelines > $amountoflocallines) then
        for $x = ($amountofremotelines-2) to $amountofremotelines
            $minidiskRemote[$x] = filereadline($simRemote, $x)
            $minidiskremote[$x] = stringtrimleft($minidiskremote[$x], 1)
            $minidiskremote[$x] = stringtrimright($minidiskremote[$x], 1)
            filewriteline($files2compress, $minidiskremote[$x])
        next
    endif
    fileclose($files2compress)  
    
; 4 & 5. Wait for confirmation (compresscomplete.txt) from main server. 
;   File will have name of file to transfer. File will then be copied to local machine into the 
;   scripts directory.
    $compresscomplete="compresscomplete.txt"

        while fileexists($compresscomplete)=0
            sleep(30000)
        wend
    
    $file=fileopen($compresscomplete, 0)
    
    $file2transfer=filereadline($file)
    
    fileclose($file)
    
    filedelete($file)
    
    $copy="copy " & $file2transfer & " " & @Scriptdir & "\"

    msgbox(0, "test", "Path to copy = " & $copy)
    runwait($copy)

; 6. Uncompress transferred file.

    $rar=@Scriptdir & "\rar.exe x " & @Scriptdir & "\compressed.rar -o+ -inull " & @Scriptdir & "\insurance.dbb\worm\"
    RUNwait($rar)

; 7. Copy .SIM file from main system, overwriting the original located on this machine. 
;   Rather than reindex, we're also going to just do a direct copy of the index files
;   (.DAT, .DC2, .DCS, .ND2, .NDS, .RL2, .RLS, .STO)
    
    $copy="copy " & $simRemote & " " & @scriptdir & "\ /Y"
    runwait($copy)
    $copy="copy \\dmay\dbbases\insuranc.dbb\insuranc.* " & @scriptdir & "\insurance.dbb\ /Y"
    runwait($copy)

; 8. Restart Docubase services.

    runwait($dbstart)

exit

It's because you're specifying a Dos switch.

if you were to take out the switch it would work or you can try this

$copy = "copy " & $simRemote & " " & @scriptdir & "\ /Y"
Try Runwait(@compspec & " /c " & $copy,"",@sw_hide)

that;s why I didnt tell you to do a runwait in your other post. it gets ugly when you introduce switches.

alternatively, you can use _rundos. it's basically the runwait(@comspec & " /c " & $yourvar,"", @sw_hide)

so that you just do _rundos($yourvar).

Edited by blademonkey

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0