Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Pushing file updates from 'root' to all domain users? |
|
Author |
|
Luth
Joined: 02 Oct 2011 Posts: 1
|
Posted: Sun 02 Oct '11 21:47 Post subject: Pushing file updates from 'root' to all domain users? |
|
|
I have a dozen websites all running the same base template. Right now, if I make a change to, say, ./include/library.inc, then I have to manually FTP into each domain directory and upload library.inc. I would much rather write a script to do it for me. Ideally, I'd like to have an /update/ directory, and then upload a file-structure there, and have the script copy it out to all domain directories. The problem is, though I do know how to program, I don't really know where to start with writing this particular script. Without a decent starting point, I don't really have the foundation necessary to teach myself.
Can someone give me a hand getting the basics down? Like, where to make the script file, what commands I should be utilizing (file copy, chown, chmod), etc.
I really appreciate any help you could give. |
|
Back to top |
|
Virsacer
Joined: 16 Jan 2010 Posts: 108 Location: Germany, Darmstadt
|
Posted: Tue 04 Oct '11 14:17 Post subject: |
|
|
The simpliest solution is probably a script on your pc.
A 2 dimensional array for the FTP Logininformation
A foreach with the FTP stuff you want done:
http://php.net/manual/en/ref.ftp.php |
|
Back to top |
|
conanman
Joined: 04 Oct 2011 Posts: 10
|
Posted: Tue 04 Oct '11 16:01 Post subject: |
|
|
1) have you looked at vbs? also known as wsh? that is by far the most powerful language on the windows platform. Google "copy files wsh vbs" and you will get loads of hits
2) you can actually do this in php too if you enable "php cli".
with either 1/2 you can run a "scheduled task" every night (or every minute if you like) to check if a file exists and if not copy it in. Both wsh vbs and php has ftp modules you can add.
3) the third option is just to php "include" it from one "giant" central location |
|
Back to top |
|
conanman
Joined: 04 Oct 2011 Posts: 10
|
Posted: Tue 04 Oct '11 18:11 Post subject: |
|
|
Code: |
'''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Author: -----
' Date: 08.06.2008
' Function: Copies via FTP all C:/www and MySQL and all subfolder
' directory files to FTP destination for back up.
'
' Run: Every 2 days
'
' Version: v1.0
'
' Notes: requires FTP freeware ActiveX library from "Chilkat"
'
' Documentation: http://www.chilkatsoft.com/refdoc/xChilkatFtpRef.html
' Download: http://www.chilkatsoft.com/download/FtpActiveX.msi
'
'''''''''''''''''''''''''''''''''''''''''''''''''''
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFS = CreateObject("Scripting.FileSystemObject")
strCurrentFolder=WshShell.CurrentDirectory
'WScript.Echo strCurrentFolder
'Get parent folder
DIM strParentFolder
strParentFolder = objFS.GetParentFolderName(strCurrentFolder)
'WScript.Echo objFS.GetParentFolderName(strCurrentFolder)
'WScript.Echo objFS.GetFolder(strCurrentFolder).Name
'Get current folder name
DIM strDatabase
strDatabase = objFS.GetFolder(strParentFolder).Name
'MySQL
DIM objShell
set objShell = wscript.createObject("wscript.shell")
iReturn = objShell.Run("%COMSPEC% /C ""mysqldump -B " & strDatabase & " -uroot -pmypassword --extended-insert=FALSE -c --add-drop-database >" & strCurrentFolder & "/" & strDatabase & ".sqldump""", 0, TRUE)
set ftp = CreateObject("Chilkat.Ftp2")
' Any string unlocks the component for the 1st 30-days.
success = ftp.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
MsgBox ftp.LastErrorText
WScript.Quit
End If
ftp.Hostname = "ftp.chilkatsoft.com"
ftp.Username = "****"
ftp.Password = "****"
' The default data transfer mode is "Active" as opposed to "Passive".
' Connect and login to the FTP server.
success = ftp.Connect()
If (success <> 1) Then
MsgBox ftp.LastErrorText
WScript.Quit
End If
' Change to the remote directory where the file will be uploaded.
success = ftp.ChangeRemoteDir("junk")
If (success <> 1) Then
MsgBox ftp.LastErrorText
WScript.Quit
End If
' Upload a file.
localFilename = "hamlet.xml"
remoteFilename = "hamlet.xml"
success = ftp.PutFile(localFilename,remoteFilename)
If (success <> 1) Then
MsgBox ftp.LastErrorText
WScript.Quit
End If
ftp.Disconnect
MsgBox "File Uploaded!"
'WScript.Echo "root found> " & Subfolder.Name & " making > """ & Replace(Subfolder.Path,"\","/") & "/" & Subfolder.Name & ".sqldump"""
|
|
|
Back to top |
|
tabestmaker
Joined: 18 Dec 2012 Posts: 4 Location: Ma
|
Posted: Sat 22 Dec '12 23:15 Post subject: |
|
|
Hey Luth You Can check Out this link in here it can work for you at least i tried and eveything looks fine
bit.ly/WFcFt0 which -> http://php.net/manual/en/ref.ftp.php
Moderator Edit: I don't like bitly links, never know what could be waiting on the other end of them. |
|
Back to top |
|
daniel
Joined: 10 Nov 2013 Posts: 2
|
Posted: Fri 15 Nov '13 16:13 Post subject: |
|
|
i found the same problem and what conanman said solve it.. thanks
cute junior clothes |
|
Back to top |
|
|
|
|
|
|