(Líder Mundial con más de 100.000 web sites alojados)
Cómo comprimir un directorio para pasar a otro web
First, you need to 'tar' up all the files, then 'gzip'
them to compress them, as 'tar' merely organizes them into a one-file
bundle. What you'll need to do is create a shell script that will go
into the parent directory, and gzip up the whole directory. Tar can do
this by calling it like: 'tar cvf /u/web/(userid)/outputfile.tar
/u/web/(userid)/(directory)'. Replace (directory) with the directory you
want to zip up. It then will call gzip to compress the file, to a more
manageable size. Call gzip with 'gzip outputfile.tar', and that will
create 'outputfile.tar.gz', which you can download off of your account.
To give you a simpler picture of this, I'll just create a simple shell
script to do this. Of course you'll have to custimize this to your
needs, including your userid and the target files and directories. Here
we go, just name it script.sh or something to that effect.
- --start of script
#!/bin/sh
echo "Content-type: text/plain"
echo ""
##
# Here's where it zips things up. Please be SURE to change
# (userid), (outputfile), and (dir to tar) to whatever is appropriate.
# It may or may not spit out messages, but include the Content-type header
# so that you don't get a '500 Server Error' when/if it does.
##
echo "Starting to zip up items..."
tar cvf /u/web/(userid)/(outputfile).tar /u/web/(userid)/(dir to tar)
# Included to let you know what is going on.
echo "Successfully tarred directory...now gzipping"
gzip /u/web/(userid)/(outputfile).tar
# Once again to keep you informed.
echo "Successfully gzipped file...ready for download"
- --end of script
Just upload that script to your /cgi-local directory, and run it from
the web ONCE, not multiple times. Or, upload it, run it, and change it
to tar up another directory. Now, once you have your outputfile.tar.gz
in its final destination, you'll obviously need to unzip it into the
appropriate places. If the destination has telnet access, you can simply
run the
following commands from the command line; but if not I write another
small shell script to unzip these on your target account. Please note that
I do not know how the target account does their directory structure, so you
will have
to find that out and edit the script accordingly. The script will create
the directories as neccessary, so just upload the file to your home
directory, and it will create its own directories. If the target
account uses a cgi
directory other than cgi-local, you will have to move the files using an
FTP client or telnet. Here's the script for decompressing it:
- --start script
#!/bin/sh
# To eliminate '500' errors, and so that status messages
# are sent to your web browser, we send the context-type header.
echo "Content-type: text/plain"
echo ""
echo "Starting to unzip files..."
gunzip /path/to/file/outputfile.tar.gz
echo "File ungzipped, now un-tarring"
tar -xvf /path/to/file/outputfile.tar # Please note that it is NOT
# .tar.gz here, as it is made
# into a tar by gunzip.
echo "Files untarred into their own directories"
echo "You may now delete outputfile.tar"
echo "-----"
echo "COMPLETE"
- --end script
I have not tested these particular scripts, so you may want to look them
over for stupid typos on my part. If you have problems with anything
here, please let me know and I will be glad to help you further. You can also find documentation for the 'tar' and 'gzip' commands on the
internet probably at http://www.linux.org/ . Look for man pages (manual pages), they will list other options and such.