Debugging the code


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Debugging the code
# 1  
Old 11-27-2006
Debugging the code

Greetings..
I'm trying to build a script to manage my Mugen's chars, adding the chars to the game, searching the chars dir for .zip and .rar files, and then listing the nemes before the dots "." to a separate file in /tmp, and then create the folders for each file, copying the compacted files to their respective folders, and then uncompressing them there.
So, well, I'm getting some erros. The script does not work with some files, but try to do the same thing two times with others.

Well, this is the environment:
Code:
-rwxr-xr-x 1 oandarilho01 users  416 2006-11-27 01:31 adiciona_char.sh
-rw-r--r-- 1 oandarilho01 users 6,2M 2006-11-02 00:19 joker.rar
drwxr-xr-x 2 oandarilho01 users  496 2002-04-21 01:53 kfm
-rw-r--r-- 1 oandarilho01 users 1,1M 2006-11-02 07:51 kiriko.zip
-rw-r--r-- 1 oandarilho01 users 3,7M 2006-10-24 00:24 kyle.zip
-rw-r--r-- 1 oandarilho01 users 3,5M 2006-11-02 00:24 ngbc_ai.rar
-rw-r--r-- 1 oandarilho01 users 3,4M 2006-11-02 07:48 ngbc_fuuma.rar
-rw-r--r-- 1 oandarilho01 users 4,2M 2006-11-02 07:48 ngbc_kisarah.rar
-rw-r--r-- 1 oandarilho01 users 2,4M 2006-10-24 00:00 oni.zip
-rw-r--r-- 1 oandarilho01 users 4,3M 2006-11-02 00:12 Oswald_XI.zip
-rw-r--r-- 1 oandarilho01 users 1,6M 2006-11-02 00:10 rai-EX.rar
-rw-r--r-- 1 oandarilho01 users  101 2002-04-21 00:45 readme.txt
-rw-r--r-- 1 oandarilho01 users 6,7M 2006-10-24 00:24 rimle.zip
-rw-r--r-- 1 oandarilho01 users 627K 2006-11-02 07:51 shampoo.zip
-rw-r--r-- 1 oandarilho01 users 1,1M 2006-10-24 00:03 tetsuo_advance.zip
-rw-r--r-- 1 oandarilho01 users 5,1M 2006-11-02 00:18 xi_elisabeth.rar
-rw-r--r-- 1 oandarilho01 users 5,4M 2006-11-02 00:27 xi_jenet.rar

And this is the script:
Code:
#!/bin/bash
# Script para ajuste de Mugen - v0.01
#
# Definindo as variáveis de ambiente:
CHARDIR=`pwd`

# Criando pasta para o char
ls -l *.zip *.rar $CHARDIR | awk -F" " '{ print $8 }' | awk -F"." '{ print $1 }' > /tmp/novos
for char in `cat /tmp/novos`; do
   mkdir $CHARDIR/$char
   cp $char.zip $CHARDIR/$char
   cd $CHARDIR/$char
   unzip $char.zip
   cd ..
done
rm /tmp/novos

Even either don't knowing or don't linking Mugen, I believe some of you could help me to improve this code..
So, I thank you all for the attention and help.
# 2  
Old 11-27-2006
Does your version of unzip have the -d option? ( man unzip )
Code:
       [-d exdir]
              An  optional directory to which to extract files.  By default, all files and
              subdirectories are recreated in the current directory; the -d option  allows
              extraction  in an arbitrary directory (always assuming one has permission to
              write to the directory).


If so, then something like this might work (only tested with .zip files):
Code:
#! /bin/bash

for X in `ls *.zip *.rar` ; do
  DIR=`echo $X | sed -e "s/^\(.*\)\.\(zip\|rar\)$/\1/g"`
  unzip $X -d $DIR
done

# 3  
Old 11-27-2006
Whow... it sounds really cool.. thanks..
I`ll try it as soon as possible!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Debugging Help needed

I am VERY much a neophyte with shell scripting. I am working on the following, "Create a script sends an email message to the user specified on the command line if any of the file systems at more than 60% of capacity. The script should not process special file systems as /proc on the... (2 Replies)
Discussion started by: doghouse308
2 Replies

2. Programming

64 bit code debugging using gdb and ddd

Hello I have built our application on AIX 7.1 as a 64 bit application. My queries are as follows: Can a 32bit gdb (v7.6) and ddd (data display debugger - v3.3.12), debug a 64bit executable ? If I have a small 64bit a.exe executable that seems to work. If I have a more complicated executable... (4 Replies)
Discussion started by: biju64
4 Replies

3. Programming

c++ debugging

hey i have a problem with a switch case in program and the debugger is messy has hell ( we use normal VI and gdb in our schoool to make it more diffiacult) any way i have a problom where for some unknown reason the debugger just skips a switch statment as if it wasent even there the rest... (2 Replies)
Discussion started by: gotenxds
2 Replies

4. UNIX for Dummies Questions & Answers

blcr debugging

hey, can any one please tell me how can i debug blcr?? actually i have checkpointd a client using blcr and i want to check out what actually happens when we checkpoint any program. so i want to see what happen when we type $cr_checkpoint pid i mean i want to debug when i enter this... (0 Replies)
Discussion started by: pratibha
0 Replies

5. Programming

Need some help in debugging the C-Progam.

Hi i want to debug the C program with GDB debugger. I want to debug the program by line by line. I want to debug program like as we debug the program in Turbo-C using the F8. Can any one help me? I know i have to use single stepping. But i don't know how to use it. Any help can be appreciated..... (5 Replies)
Discussion started by: ps_sach
5 Replies

6. Programming

Debugging 64bit code with gdb and ddd in AIX

I'm trying to use the GDB debugger and DDD to debug 64bit code. It seems that the AIX toolkit gdb version 6.0 works with 64bit code. But the ddd tool when running gdb gives the following errors : Starting program: <my binary> <my params> warning: "": not in executable format: There is an input... (2 Replies)
Discussion started by: bean66
2 Replies

7. Solaris

debugging

when I tried to debug my application i got the following. gdb -v GNU gdb 6.6 file is in C and Xmotiff Languages (gdb) attach 25499 Attaching to process 25499 Retry #1: Retry #2: Retry #3: Retry #4: 0xfea40b68 in ?? () (gdb) where #0 0xfea40b68 in ?? () (0 Replies)
Discussion started by: satish@123
0 Replies

8. Programming

function debugging. help

Hi, I tried creating my version of the cat function in bash but left it and now I'm trying to make this function work, but it wouldn't. #include <sys/param.h> #include <sys/stat.h> #include <locale.h> #include <ctype.h> #include <err.h> #include <errno.h> #include <fcntl.h>... (2 Replies)
Discussion started by: sanchopansa
2 Replies

9. UNIX for Advanced & Expert Users

Debugging a c/c++ program

Can anyone tell the commands we use for debugging a programm in dbx with explanation for each? Iam totally new to unix environment (3 Replies)
Discussion started by: bogarams
3 Replies

10. Shell Programming and Scripting

Regarding Debugging

Hi, If we want to debug a shell script, then set -vx has to be included in the begining of the script. Just i want to know what purpose -vx is used. Thanks in advace Sarwan (2 Replies)
Discussion started by: sarwan
2 Replies
Login or Register to Ask a Question