mimil2007
Messages postés4Date d'inscriptionmercredi 21 novembre 2007StatutMembreDernière intervention21 novembre 2007
-
21 nov. 2007 à 12:29
cboulas
Messages postés2641Date d'inscriptionmercredi 2 juin 2004StatutMembreDernière intervention 8 janvier 2014
-
21 nov. 2007 à 14:14
Bonjour ,
Je vous soumets un script que je fais pour le boulot ,ce script à pour but de faire des transfert de fichiers entre un serveur unix (HP-UX) et une station windows (XP)
Il n'y a que la station windows qui peut récupérer les fichiers d'ou le vbs.
Le transfert se fait via clef ssh en utilisant winscp en ligne de commande ,ensuite il y'a une tache planifié qui l'execute toutes les deux minutes (dans ce script je transfert deux fois les fichiers de manière a etre sur que tout est arrvivé)
Je ne m'y connais pas trop en vbs (admin unix) si vous pouviez m'aider .Merci
PS : La ligne qui me pose soucis est en rouge (j'ai beaucoup de soucis avec les guillemets),c'est un problème de langage
' *** SCRIPT DE COMPARAISON DES FICHIERS ENVOYES A RECLAVTS ****
' *** les fichiers sont transférés et récupérés pour êtres sûr de leurs transferts
Option Explicit
''' Déclaration des variables de travail '''
'on error resume next
DIM objShell
Dim oFSO,WshShell
Dim sDirectoryPath
Dim oFolder
Dim oFileCollection
Dim oFile
Dim iExtension
''' Déclaration de l'environnement de travail '''
Set WshShell = WScript.CreateObject("WScript.Shell")
iExtension = "TXT" ' EXTENSION des fichiers à supprimer
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = "C:\Temp\verif" ' Répertoire de travail
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files
''' Boucle : lit tous les fichiers du répertoire "sDirectoryPath" '''
For each oFile in oFileCollection
IF oFSO.getextensionname(oFile) = iExtension Then
delfile(oFSO.getfilename(oFile))
End If
Next
''' On sort proprement : variables à 0 '''
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing
sub delfile(oFile)
Dim oFSO2,WshShell2
Dim sDirectoryPath2
Dim oFolder2
Dim oFileCollection2
Dim oFile2
Set WshShell2 = WScript.CreateObject("WScript.Shell")
Set oFSO2 = CreateObject("Scripting.FileSystemObject")
sDirectoryPath2 = "C:\Temp\verif2" ' Répertoire de travail
set oFolder2 = oFSO2.GetFolder(sDirectoryPath2)
set oFileCollection2 = oFolder2.Files
For each oFile2 in oFileCollection2
if oFSO2.getfilename(oFile2) = oFile then
iReturn = WshShell.Run("""CMD /C winscp.com"" /log=C:\Temp\move.log root@machine_unix /privatekey=C:\Temp\clef_ssh.ppk /command call mv /admin/test/A_Traiter/*.txt /admin/test/Traiter""", , True)
end if
Next
Set oFSO2 = Nothing
Set oFolder2 = Nothing
Set oFileCollection2 = Nothing
Set oFile2 = Nothing
end sub
mimil2007
Messages postés4Date d'inscriptionmercredi 21 novembre 2007StatutMembreDernière intervention21 novembre 2007 21 nov. 2007 à 14:02
Ce qui fonctionne en manuel ,par contre dans le script ça ne fonctionne pas
J'ai un pop-up avec cette erreur :
Script : C:\Temp\movefictraiter.vbs
Ligne : 96
Caract : 31
Erreur : ')' attendu
Code : 800A03EE
Source : Erreur de compilation Microsoft VBScript
C:\Documents and Settings\terrierc>CMD /C winscp.com /log=C:\Temp\move.log root@machine_unix /privatekey=C:\Temp\clef_ssh.ppk /command "call mv /admin/test/A_Traiter/*.txt /admin/test/Traiter"
Searching for host...
Connecting to host...
Authenticating...
Using username "root".
Authenticating with public key "clef_ssh".
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] root@machine_unix
Searching for host...
Connecting to host...
Authenticating...
Using username "root".
Authenticating with public key "clef_ssh".
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Vous n’avez pas trouvé la réponse que vous recherchez ?