The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Accessing variables of one shell script in another shell script rsendhilmani Shell Programming and Scripting 2 03-17-2009 01:17 AM
invoking a shell script inside cgi shell script smriti_shridhar Shell Programming and Scripting 2 07-09-2008 02:50 AM
Accessing variables of one shell script in another shell script looza Shell Programming and Scripting 2 06-30-2008 08:13 PM
How to Run a shell script from Perl script in Parent shell? hifake Shell Programming and Scripting 16 08-28-2007 09:42 PM
Have a shell script call another shell script and exit heprox Shell Programming and Scripting 2 11-20-2006 08:17 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-22-2009
xeco xeco is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 1
Shell Script (help me)

Hello!!!

I am doing a project, and i need help, so i would stay very apreciate if anybody help me... sorry for my english.

the project is, havind a .txt and i want to convert it for pdf, so i would like that u help me...

Code:
#!/bin/sh

OLDIFS=$IFS
IFS='
'


File_Out()
{
  for LINHAS in `cat fdados2.txt`
  do
      CURSO=`echo $LINHAS | cut -d'|' -f2`
      LOGIN=`echo $LINHAS | cut -d'|' -f3`
      PPASSE=`echo $LINHAS | cut -d'|' -f4`
      NUMERO=`echo $LINHAS | cut -d'|' -f5`
      NOME=`echo $LINHAS | cut -d'|' -f6`

      printf "________________________________________________________" >> fPronto.txt
      printf " \n\n | CURSO:%s  NUMERO:%s \n | LOGIN:%s  PPASSE:%s \n | NOME:%s\n" $CURSO $NUMERO $LOGIN $PPASSE $NOME >> fPronto.txt

  done
}


Conteudo_Linhas()
{
  N_LINHAS=$(cat fdados1.txt | wc -l )
  echo " $N_LINHAS Linhas";
}



Dados_Aleatorios()
{
  
  for LINHAS in `cat novo.txt`
  do
  
      NUM=`echo $LINHAS | cut -d'|' -f5`
      printf "\n %s"$NUM >>  novo1.txt
    
  done
}



Ordenar_Dados()              #Esta funcao funciona pq o ficheiro de dados e pequeno, atraves de um ciclo de i(numero de linhas)vezes#
{                         # podiamos ordener qualquer ficheiro de dados #
  J=0
  K=0
  for LINHAS in `cat novo1.txt`
  do
      
      N=`echo $LINHAS`
      if test $N -gt $K
         then
            if test $J -eq 0
               then
                J=$K
                K=$N 
               else
                printf "\n %s"$N >> novo2.txt   
            fi   
         else
            if test $N -gt $J
               then
                  printf "\n %s"$J >> novo2.txt
                  J=$N
               else
                  printf "\n %s"$N >> novo2.txt                    
            fi  
      fi

  done            
  printf "\n %s"$K >> novo2.txt
  printf "\n %s"$J >> novo2.txt
  J=0
  K=0    
}                   


File_End()
{                    
  for LINHAS in `cat novo2.txt`
  do
      L=`echo $LINHAS`
      for LINHAS in `cat novo.txt`
      do
          LIN=`echo $LINHAS`
          LN=`echo $LINHAS | cut -d'|' -f5`
          if test $L -eq $LN
             then
              printf "\n %s"$LIN >> fdados2.txt
          fi
      done
  done
}          
  
##### PRINCIPAL #######################################

OLDIFS=$IFS
IFS='
'

echo " Digite o nome do ficheiro"
read file

if [ -s $file ]
   then

    i=0;

    for LINHAS in `cat $file`
    do
        i=$(expr $i + 1)
    done

    h=$(expr $i - 3) 
    T=`tail --lines=$h $file`
    echo "$T" >> novo.txt
    
    Dados_Aleatorios $novo.txt 
    
    Ordenar_Dados $novo1.txt
    rm novo1.txt    
    File_End $novo2.txt $novo.txt     
    rm novo.txt
    rm novo2.txt
    File_Out $fdados2.txt   
    rm fdados2.txt
  
    a2ps --columns=2 --output=Pronto.ps --sides=simplex fPronto.txt
    rm fPronto.txt
    ps2pdf Pronto.ps
    rm Pronto.ps
   else
    echo "$file : Erro: ficheiro nao existe ou nao especificado"
fi

tks.. to every one

Last edited by pludi; 10-22-2009 at 01:32 PM.. Reason: code tags please
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0