Urban Terror Forums: script for demos - Urban Terror Forums

Jump to content

 Login | Register 
Advertisement
  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • This topic is locked

script for demos Rate Topic: -----

#11 User is offline   HoboHumpinSlut (old) Icon

  • Joined: 07-February 04
  • Posts: 2,308

Posted 01 April 2005 - 04:55 PM

Quote

OMG Geeky Nerds!!!!!!!!!!!!!!!!!!

who has read the whole thread here?

#12 User is offline   CorlacolII (old) Icon

  • Joined: 03-June 04
  • Posts: 44

Posted 13 April 2005 - 08:36 PM

[quote name='"Trolan"]Wow' date=' people actually use the variable flags? ;) I never got too into fiddling with them as it seems every flavor of shell has their own syntax, whereas most of the rest of the code syntax tends to be fairly standardized. Does make it a bit more concise.[/quote']

hmmm you are partially right.

${var%%blah} and ${var##blah} are pretty default. Also called POSIX compliant. So if you want to write a shell script that works anywhere you'd have to google for posix and sh. For a only POSIX supporting shell use ash, and for lots of nice examples look at any gnu configurefile, generated by autoconf.

bash is an embrace and extend version of a POSIX shell. So even with the --posix option you still have support for for instance arrays. Which is the reason so many people write shell scripts which only work on bash.

#13 User is offline   Trolan (old) Icon

  • Joined: 27-June 04
  • Posts: 190
  • LocationMilpitas, CA

Posted 13 April 2005 - 10:49 PM

I tend to stick with csh if I'm writing for something on *BSD, or sh/ksh if it's meant to be portable across Unices. I've had too many things which rely on certain functionality in GNU tools break over time to not be leery of using less-commonly used extensions. If the code gets too involved, I just jump to Perl instead.

#14 User is offline   dborg (old) Icon

  • Joined: 06-December 06
  • Posts: 477
  • LocationGermany

Posted 07 April 2007 - 08:30 PM

I prefer simple solutions. ;) This is the little helper script I use to open demos directly by doubleclicking from Nautilus or whatever:


#!/bin/bash

CMD="urbanterror"
PROT="68"
DIR="$HOME/.q3a/q3ut4/demos"

ln -sf $1 "$DIR/LATESTREPLAY.dm_$PROT"
$CMD +demo "LATESTREPLAY.dm_$PROT"



This also should work fine with temporary files, for example to open a demo directly from the internet or from an archive without extracting (haven't tested it yet with this particular script). I find this very convenient, whether the ingame demo browser works or not.

#15 User is offline   mitsubishi Icon

  • Account: mitsubishi
  • Country:
  • Joined: 28-February 10
  • Posts: 13,481

Posted 07 April 2007 - 09:53 PM

hey there ..2.5 year old thread

:evil:

bullet_loaderAdvertisement

#16 User is offline   dborg (old) Icon

  • Joined: 06-December 06
  • Posts: 477
  • LocationGermany

Posted 07 April 2007 - 10:41 PM

But still relevant. ;)

#17 User is offline   undead Icon

  • Account: undead
  • Joined: 06-June 10
  • Posts: 199

Posted 08 April 2007 - 03:25 AM

I want to get in on this 2.5 year old thread!


#!/usr/bin/perl -w

# Script to rename demo files on Linux.
# It should be an all upper case name before the lower case ".dm_68" at the end.

use strict;
use warnings;
use Fatal qw(opendir closedir);

my $dir = "$ENV{HOME}/.q3a/q3ut4/demos";

opendir(my $dir_handle, $dir);

while (my $entry = readdir($dir_handle)) {
  # Only look at files that should be renamed (skip properly named)
  if (-f "$dir/$entry" && $entry =~ /^(.*[a-z]+.*)(.dm_68)$/) {
    my $new_name = uc($1) . $2;

    print "Renaming $dir/$entry to $dir/$new_namen";
    rename "$dir/$entry", "$dir/$new_name";
  }
}

closedir($dir_handle);



Isn't it funny how everyone has their own way of doing it? :D

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users

Advertisement


Copyright © 1999-2024 Frozensand Games Limited  |  All rights reserved  |  Urban Terror™ and FrozenSand™ are trademarks of Frozensand Games Limited

Frozensand Games is a Limited company registered in England and Wales. Company Reg No: 10343942