Script vbs

Résolu
mimil2007 Messages postés 4 Date d'inscription mercredi 21 novembre 2007 Statut Membre Dernière intervention 21 novembre 2007 - 21 nov. 2007 à 12:29
cboulas Messages postés 2641 Date d'inscription mercredi 2 juin 2004 Statut Membre Derniè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

5 réponses

cboulas Messages postés 2641 Date d'inscription mercredi 2 juin 2004 Statut Membre Dernière intervention 8 janvier 2014 16
21 nov. 2007 à 13:12
Salut

et en mettant :

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)

Chris...
Web : Firstruner
3
mimil2007 Messages postés 4 Date d'inscription mercredi 21 novembre 2007 Statut Membre Dernière intervention 21 novembre 2007
21 nov. 2007 à 13:39
Je testes et je te dis ça fonctionne
3
mimil2007 Messages postés 4 Date d'inscription mercredi 21 novembre 2007 Statut Membre Dernière intervention 21 novembre 2007
21 nov. 2007 à 13:45
ça ne fonctionne pas voici le resultat quand je la lances dans une fenetre DOS :

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
Missing parameter for command 'call'.
Missing parameter for command 'mv'.
Unknown command '/admin/test/A_Traiter/*.txt'.
Unknown command '/admin/test/Traiter'.
winscp>
3
mimil2007 Messages postés 4 Date d'inscription mercredi 21 novembre 2007 Statut Membre Dernière intervention 21 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.
3

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cboulas Messages postés 2641 Date d'inscription mercredi 2 juin 2004 Statut Membre Dernière intervention 8 janvier 2014 16
21 nov. 2007 à 14:14
c'est sûr que c'est une histoire de "

je vais tester un peu sur un soft pour passer les arguments car c'est ce qui bloque

Chris...
Web : Firstruner
3
Rejoignez-nous