auto creating 3 lists using filetypes
ok after you guys helped me with random map script it got me thinking of other possible uses to make life easier on the server and i renebered theres 3 identicle list files that i have to hand type and add to everytime i add maps to the server
heres what i`d like a script to do scan the /home/mrgreaper/srcds_1/cstrike/maps/ folder for all *.bsp and all *.nav file formats create a list of all files that have both *.bsp and *.nav remove the extensions and dump into 3 text files replacing the prevouse contents Code:
#!/bin/sh the above im guesing at using the example someone posted when i needed a random map then i need some way to compare the two files since we have already removed the extensions then i would want to keep 1 of what ever duplicates in the lists so if list one was de_dust de_rats cs_office and list 2 was de_dust cs_office then the duplicates would be de_dust and cs_office so i would want those two names to in my list like so list3; de_dust cs_office the returns after each name are also important Code:
List3= compare part of the script i have no idea Code:
cd /home/mrgreaper/srcds_1/cstrike |
You can use something like
Code:
list3="$(echo -e "$maps$navs"|sort -d|uniq -d)" You also need to replace the 1st and "(" and last ")" with qutes from the maps and navs variables or you'll get a "(" on the 1st file and a "(" on the last one. Also wnen you want to put the list in to a file use Code:
echo -e "$list3" |
i think im doing it wrong
Code:
#!/bin/sh then displays on the screen /home/mrgreaper/test.txt the file test.txt however is blank :( any ideas where im going wrong? |
You havent done the redirect right,
the last command needs to be Code:
echo -e "$list3" > /home/mrgreaper/test.txt |
changed the last line as above but it still just an empty test.txt file
i have tried chmod 777 it as well not sure it would make a difference ....and it didnt :( wish i knew what is wrong with it |
1st change
Code:
maps=($(find $mapdir -type f -name "*.bsp" -exec basename "{}" .bsp \;)) Code:
maps="$(find $mapdir -type f -name "*.bsp" -exec basename "{}" .bsp \;)" Code:
#!/bin/sh |
Quote:
i`m a moron Code:
navs="$(find $mapdir -type f -name "*.nav" -exec basename "{}" .bsp \;)" Code:
navs="$(find $mapdir -type f -name "*.nav" -exec basename "{}" .nav \;)" worked perfectly with above changes thnx guys is there a site i can see a list of commands with detailed descriptions i looked at the one on this site the wiki but it discribes non of the echo commands that you guys shown me ? the one last thing i need to do with the script is to make it spill a list of unique names so using my original example Quote:
de_rats now its clearly to do with ; list4="$(echo -e "$maps$navs"|sort -d|uniq -d)" the red bit |
To be fair, I should have seen that line too, so your not the only moron :p
There are sites with lists of commands and descriptions, and there's always the man pages "man (command)", because there are a lot of linux commands and they change from distro to distro I'm not sure you'll find a site with every command on it. But there are sites with man pages indexed by name like [http://manpages.debian.net/by_man.html] but you can spend DAYS looking thru all of them. You'll want some tutorials in scripting, eg. search google for "bash scripting" and things like "howto (what your trying to do) bash", chance is you'll find something helpful. Now about that last command you want to run. "list4="$(echo -e "$maps$navs"|sort -d|uniq -d)" would turn in to "list4="$(echo -e "$maps$navs"|sort -d|uniq -u)" take a look at "uniq --help" and "man uniq" for more options, it's a nice little command to know about. |
Here's 3 links you may find useful:
http://rute.2038bug.com/index.html.gz http://www.tldp.org/LDP/abs/html/index.html http://www.faqs.org/docs/bashman/bashref.html#SEC_Top |
|
thank you gotta sort my samba problem out then i shall have a read of those sites
|
just how advanced can you get with this!
the purpose of the above script is because the game i host for my mates uses bots now they need a nav file associated with every map so for the bots to play cs_office there needs to be cs_office.bsp and cs_office.nav if cs_office doesnt exist it creates it slowly between 20minutes and 2 hours sometimes longer and often crashing the server so i download the map on my pc load up cstrike using nav file editing button cfgs and edit/create one my self then copy the nav file acoss and xtract the map file to the server (maps have material files sound files model files allsorts or just bsp files) any way what im curiouse about is this possible ; say the structer of the cstrike folder (the draws im interested in at anyrate) cstrike --materials ---levelname1 ---levelname2 ---levelname3 ---etc etc --sounds --maps ---soundcache ---graphes --models could a script be made that would look at the local /cstrike folder look at the cstrike folder on a network pc and if it finds any files on the network pc it copys them to the relevent folder on the local pc for example say i download onto my pc a map called cs_office nd that contains the following files / folders --materials ---cs_office ----office.vmf ----moniter.vmf --sound ---speakers.mp3 ---vending.mp3 ---someother.mp3 --maps ---cs_office.bsp ---cs_office.nav ---cs_office.txt ---soundcache ---cs_office.cache and ran the script would it realise the above folders where different and even that a new folder had been created and then copy the files to the local folders so the server had the same files? i thnk perhaps im asking to much but i have been plesently surprised so far so remain optimistic |
rsync is your friend ....
|
or "wget" if the remote machine has an FTP access.
|
rsync looks way above my competent computing level :(
i could easily install a windows ftp server on my main pc how would i use wget to copy any file changes across to the sever and make sure they go to the right folders? i did have a quick read of the wget manual manly the examples but couldnt see anything right i`m gussing its not as simple as wget --ftp-user=user --ftp-password=password my.ftp.ip/maps/*.* /home/mrgreaper/srcds_1/cstrike/maps/*.* |
All times are GMT -5. The time now is 08:16 PM. |