| | |
Need some help with compression / move script
![]() |
•
•
Join Date: Aug 2007
Posts: 7
Reputation:
Solved Threads: 0
Hi.
iv'e been looking around the web trying to find a suitable script to use with my hltv servers , unfortunately to no avail
.
I'm just wondering if anyone here could perhaps help me out with a shell script to do what i need it to , i would be most grateful .
Here is what i need from the script :
Basically i run a lot of game servers ( may be able to offer whoever helps me something as im an admin of a very big server provider ) , so what i need from the shell script is for it to scan my hltv's directories for any .dem files , then i need it to compress them ( preferabbly in zip format) , then i need it to move the zipped files to a web directory , and then delete the original .dem files .
i did find a script that i thought would work which was this :
#!/bin/bash
HLDS=/home/dlmczt/hlds/czero/ #Working directory where demos are
REP=/var/www/html/czhltv/ #copying directory
#FORMAT="tar cvf"
#EXTENSION=tar
FORMAT=zip #Compression using ZIP
EXTENSION=zip #Associated extension
cd $HLDS
for files in `ls *.dem` do
$FORMAT $files.$(date +%s).$EXTENSION $files
echo "$files.$(date +%s).$EXTENSION compressed"
mv $files.$(date +%s).$EXTENSION $REP
echo "$files.$(date +%s).$EXTENSION moved"
rm $files
echo "$files deleted"
done;
echo "Demos are available in : $REP"
however all i got when i tried to run it was :
./zipped.sh: line 10: syntax error near unexpected token `$FORMAT'
./zipped.sh: line 10: ` $FORMAT $files.$(date +%s).$EXTENSION $files'
i tried using the full path to the interpreter and other things , but no joy .
if you think you can fix this problem then that would be great and probably save alot of time .
If not is there anyone who could make me a script ? , i can tell you any paths you need .
the distro is Fedora Core 4 .
Thanks in Advance.
iv'e been looking around the web trying to find a suitable script to use with my hltv servers , unfortunately to no avail
.I'm just wondering if anyone here could perhaps help me out with a shell script to do what i need it to , i would be most grateful .
Here is what i need from the script :
Basically i run a lot of game servers ( may be able to offer whoever helps me something as im an admin of a very big server provider ) , so what i need from the shell script is for it to scan my hltv's directories for any .dem files , then i need it to compress them ( preferabbly in zip format) , then i need it to move the zipped files to a web directory , and then delete the original .dem files .
i did find a script that i thought would work which was this :
#!/bin/bash
HLDS=/home/dlmczt/hlds/czero/ #Working directory where demos are
REP=/var/www/html/czhltv/ #copying directory
#FORMAT="tar cvf"
#EXTENSION=tar
FORMAT=zip #Compression using ZIP
EXTENSION=zip #Associated extension
cd $HLDS
for files in `ls *.dem` do
$FORMAT $files.$(date +%s).$EXTENSION $files
echo "$files.$(date +%s).$EXTENSION compressed"
mv $files.$(date +%s).$EXTENSION $REP
echo "$files.$(date +%s).$EXTENSION moved"
rm $files
echo "$files deleted"
done;
echo "Demos are available in : $REP"
however all i got when i tried to run it was :
./zipped.sh: line 10: syntax error near unexpected token `$FORMAT'
./zipped.sh: line 10: ` $FORMAT $files.$(date +%s).$EXTENSION $files'
i tried using the full path to the interpreter and other things , but no joy .
if you think you can fix this problem then that would be great and probably save alot of time .
If not is there anyone who could make me a script ? , i can tell you any paths you need .
the distro is Fedora Core 4 .
Thanks in Advance.
•
•
Join Date: Aug 2007
Posts: 7
Reputation:
Solved Threads: 0
OK , well it kind of works , but im getting this now :
adding: vswildfire-0706242023-de_cpl_fire.dem (deflated 83%)
vswildfire-0706242023-de_cpl_fire.dem.1187967195.zip compressed
mv: cannot stat `vswildfire-0706242023-de_cpl_fire.dem.1187967195.zip': No such file or directory
vswildfire-0706242023-de_cpl_fire.dem.1187967195.zip moved
vswildfire-0706242023-de_cpl_fire.dem deleted
Demos are available in : /var/www/html/cztv/
it does this on most files , and only actually moves some , although it zips all of them , but i had to move the ones it hadn't manually .
any ideas ?
Thanks again .
b1ue
adding: vswildfire-0706242023-de_cpl_fire.dem (deflated 83%)
vswildfire-0706242023-de_cpl_fire.dem.1187967195.zip compressed
mv: cannot stat `vswildfire-0706242023-de_cpl_fire.dem.1187967195.zip': No such file or directory
vswildfire-0706242023-de_cpl_fire.dem.1187967195.zip moved
vswildfire-0706242023-de_cpl_fire.dem deleted
Demos are available in : /var/www/html/cztv/
it does this on most files , and only actually moves some , although it zips all of them , but i had to move the ones it hadn't manually .
any ideas ?
Thanks again .
b1ue
•
•
Join Date: Aug 2007
Posts: 165
Reputation:
Solved Threads: 18
Try the following. It now 'moves' the file into the ZIP, verifies the integrity of the new archive, and it creates the ZIP file in the destination directory.
I made a few other readability changes. And remember, 'man zip' is your friend. Granted, it may seem like gobbledegook at first, but it *does* tell you what you can do with it.
Shell Scripting Syntax (Toggle Plain Text)
#!/bin/bash HLDS="/home/dlmczt/hlds/czero/" # Working directory where demos are REP="/var/www/html/czhltv" # Copying directory ARCHIVE="zip -T -m" # Compression using ZIP EXTENSION="zip" # Associated extension cd $HLDS for demfile in *.dem do $ARCHIVE $REP/$demfile.$(date +%s).$EXTENSION $demfile echo "$demfile moved into $REP/$demfile.$(date +%s).$EXTENSION" done
I made a few other readability changes. And remember, 'man zip' is your friend. Granted, it may seem like gobbledegook at first, but it *does* tell you what you can do with it.
Last edited by Fest3er; Aug 24th, 2007 at 1:26 pm.
•
•
Join Date: Aug 2007
Posts: 7
Reputation:
Solved Threads: 0
ok changed :
for demfile in *.dem do
to
for demfile in *.dem; do
and changed this path :
REP="/var/www/html/czhltv"
to
REP="/var/www/html/cztv"
and it all works !!!
only thing i want to do now is set it up on a cron job , so that it runs every say 20 minutes .
Thanks so much for this help , it's very much appreciated .
for demfile in *.dem do
to
for demfile in *.dem; do
and changed this path :
REP="/var/www/html/czhltv"
to
REP="/var/www/html/cztv"
and it all works !!!
only thing i want to do now is set it up on a cron job , so that it runs every say 20 minutes .
Thanks so much for this help , it's very much appreciated .
•
•
Join Date: Aug 2007
Posts: 7
Reputation:
Solved Threads: 0
All Done and All Working .
Here is the final syntax incase anyone else finds it useful .
#!/bin/bash
HLDS="/home/dlmczt/hlds/czero/" # Working directory where demos are
REP="/var/www/html/hltv/cztv" # Copying directory
ARCHIVE="zip -T -m" # Compression using ZIP
EXTENSION="zip" # Associated extension
cd $HLDS
for demfile in *.dem; do
$ARCHIVE $REP/$demfile.$(date +%s).$EXTENSION $demfile
echo "$demfile moved into $REP/$demfile.$(date +%s).$EXTENSION"
done
And My Crontab entry to run every 30 mins is :
30 * * * * /home/dlmczt/hlds/autozip.sh > /dev/null
Thanks Guys , hope this helps others.
Here is the final syntax incase anyone else finds it useful .
#!/bin/bash
HLDS="/home/dlmczt/hlds/czero/" # Working directory where demos are
REP="/var/www/html/hltv/cztv" # Copying directory
ARCHIVE="zip -T -m" # Compression using ZIP
EXTENSION="zip" # Associated extension
cd $HLDS
for demfile in *.dem; do
$ARCHIVE $REP/$demfile.$(date +%s).$EXTENSION $demfile
echo "$demfile moved into $REP/$demfile.$(date +%s).$EXTENSION"
done
And My Crontab entry to run every 30 mins is :
30 * * * * /home/dlmczt/hlds/autozip.sh > /dev/null
Thanks Guys , hope this helps others.
![]() |
Similar Threads
- Zip files, move files, delete source (help me please) (Shell Scripting)
- script for fedora core 4 (Shell Scripting)
- Upload/Download Script... with compression? (PHP)
- I Cannot Delete, Move, or Rename a File On My PC. (Viruses, Spyware and other Nasties)
- Log file rotation script (Perl)
- Minor problem with some script... (C)
- Hotoffers get me mad !! (Viruses, Spyware and other Nasties)
- Bash shell screipt help (Shell Scripting)
- Automating a copy/move (Windows NT / 2000 / XP)
Other Threads in the Shell Scripting Forum
- Previous Thread: "set -o notify" for job runing background in Bash
- Next Thread: hi all please help me in this issue.
| Thread Tools | Search this Thread |





