Created
February 18, 2018 23:02
-
-
Save gdm/dec87e5d3b8950278b135c5744c4c067 to your computer and use it in GitHub Desktop.
Uploads all files and folders recursively to the WebDAV folder passed in the url
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use File::Find; | |
| my $script = ""; | |
| sub wanted() { | |
| my $f = $File::Find::name; | |
| if (-f $f) { | |
| $script .= "put '$f'\n"; | |
| } else { | |
| $script .= "cd '$target_dir'\n"; | |
| $script .= "mkdir '$f'\n"; | |
| $script .= "cd '$f'\n" | |
| } | |
| } | |
| my $url = $ARGV[0]; | |
| print "URL: $url"; | |
| if ($url =~ m#https://.*?(/\S*)#) { | |
| my $target_url = "$0"; | |
| my $target_dir = "$1"; | |
| find({'wanted'=>\&wanted, 'no_chdir' => 1}, "."); | |
| $pid = open(POUT, "| cadaver $url"); | |
| print POUT $script; | |
| print POUT "bye\n"; | |
| close POUT; | |
| } else { | |
| print "Usage: davpush.pl https//<hostname>:<port>/<upload path>\n"; | |
| print "\n"; | |
| print "Uploads all files and folders recursively to the WebDAV folder passed in the url."; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment