Necesito ayuda para shell-Script

Soy un estudiante con nociones muy basicas sobre linux. Necesito ayuda para desarrollar una practica. Por Favor, si alguien cree q puede ayudarme, que me avise y le dire cual es la practica. Gracias por anticipado.

1 respuesta

Respuesta
1
OK!
Que es lo que necesitas
Para poder mandar varios shells script para que con la aydua del man y internet y algunas paginas de linux en español te termines de ayudar!
Necesito realizar un shell-script q cuente el numero de bloques ocupados por los siguientes tipos de ficheros:
1) ficheros de bloque
2) Ficheros especiales de caracteres
3) directorios
4) Pipes
5) Ficheros ordinarios
6) enlaces
Gracias por anticipado.
Te mandare una serie de shell
Para que veas la utilizacion de comandos del ambien shell script!
Este es uno:
---.
#!/bin/ksh
umask 0022
schema=`pwd | cut -d\/ -f5`
filetype=`pwd | cut -d\/ -f6`
case ${filetype} in
forms)
source=fmb
target=fmx
schema=${schema}/forms
moduletype=form
;;
libs)
source=pll
target=plx
schema=${schema}/libs
moduletype=library
;;
menues)
source=mmb
target=mmx
schema=${schema}/libs
moduletype=menu
;;
esac
[ $# -eq 0 ] && lista="*.${source}" || lista=$*
for files in ${lista}
{
file=`basename ${files} .${source}`
f60genm \
module=${file}.${source} \
userid=$UD \
output_file=/u3/samiweb/${schema}/${file}.${target} \
module_type=${moduletype} \
batch=no \
compile_all=special
}
----------------
----------------
aqui te va otro:
# compile.sh version 2.0
# Project Manager
pid=$$ # current process identifier
trap "rm -f /tmp/${file}.${pid}.err; exit 1" 1 2 9 15
umask 0022
error() {
echo "error"
more /tmp/${file}.${pid}.err
echo -n "$*. (Y/N)? "; read dummy
[ "${dummy}~" == "N~" -o "${dummy}~" == "n~" ] && {
rm -f /tmp/${file}.${pid}.err; exit 1
}
}
basesource=`pwd | cut -d\/ -f4`
schema=`pwd | cut -d\/ -f5`
filetype=`pwd | cut -d\/ -f6`
case ${basesource} in
sami)
basetarget=samiweb
userid="sis/sis@rac"
;;
sami_girardot)
basetarget=sami_girardot
userid="sis/sis@client6"
;;
esac
case ${filetype} in
forms)
source=fmb
target=fmx
schema=${schema}/forms
moduletype=form
;;
libs)
source=pll
target=plx
schema=${schema}/libs
moduletype=library
;;
menues)
source=mmb
target=mmx
schema=${schema}/libs
moduletype=menu
;;
reports)
source=rdf
target=rep
schema=${schema}/reports
;;
esac
echo "Setup:
Base source ... [${basesource}]
Base target ... [${basetarget}]
Schema ........ [${schema}]
User id ....... [${userid}]
"
[ $# -eq 0 ] && lista="*.${source}" || lista=$*
for files in ${lista}
{
file=`basename ${files} .${source}`
echo -n "Compiling ${file}.${source}..."
case ${filetype} in
reports)
rwcon60 \
source=${file}.${source} \
userid=${userid} \
stype=rdffile \
dtype=repfile \
batch=yes \
overwrite=yes 1>/tmp/${file}.${pid}.err 2>/dev/null ||
error "Do you want keep compiling Reports" && {
echo "done"
mv -f ${file}.${target} /u3/${basetarget}/${schema}/
}
;;
forms)
f60genm \
module=${file}.${source} \
userid=${userid} \
output_file=/u3/${basetarget}/${schema}/${file}.${target} \
module_type=${moduletype} \
batch=no \
compile_all=special 1>/tmp/${file}.${pid}.err && echo "done" ||
error "Do you want keep compiling Forms"
;;
libs)
f60genm \
module=${file}.${source} \
userid=${userid} \
output_file=/u3/${basetarget}/${schema}/${file}.${target} \
module_type=${moduletype} \
batch=no \
compile_all=special 1>/tmp/${file}.${pid}.err && echo "done" ||
error "Do you want keep compiling Libs"
;;
menues)
f60genm \
module=${file}.${source} \
userid=${userid} \
output_file=/u3/${basetarget}/${schema}/${file}.${target} \
module_type=${moduletype} \
batch=no \
compile_all=special 1>/tmp/${file}.${pid}.err && echo "done" ||
error "Do you want keep compiling Menues"
;;
esac
rm -f /tmp/${file}.${pid}.err
}
exit 0
#!/bin/sh
# Compile_objects.sh version 1.0
# Copyrigth (c) MJTR System C.A.
# Product SAMI
Clear
Echo -e 'User/Shema: system'
Echo -n 'Password: '
Read password
Echo -n 'Database: '
Read database
sqlplus system/$password@$database << OEF
set serveroutput on size 1000000
DECLARE
CURSOR c1 IS
SELECT DECODE(A.OBJECT_TYPE,'PACKAGE BODY','PACKAGE',A.OBJECT_TYPE) OBJECT_TYPE
,A.OBJECT_NAME
,A.OWNER
FROM DBA_OBJECTS A
WHERE A.STATUS = 'INVALID'
-- AND A.OWNER = 'RM' --si queremos compilar un solo usuario
AND NOT EXISTS ( SELECT B.NAME
FROM DBA_ERRORS B
WHERE A.OBJECT_NAME = B.NAME
-- AND B.OWNER = 'RM'
);
c1rec c1%ROWTYPE;
V_OBJECTS VARCHAR2(500);
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO c1rec;
EXIT WHEN c1%NOTFOUND;
V_OBJECTS := 'ALTER '||C1REC.OBJECT_TYPE||' '||C1REC.OWNER||'.'||C1REC.OBJECT_NAME||' COMPILE ';
DBMS_OUTPUT.PUT_LINE(V_OBJECTS);
execute immediate V_OBJECTS;
END LOOP;
CLOSE c1;
IF V_OBJECTS IS NULL THEN
DBMS_OUTPUT.PUT_LINE('They were not objects to compile');
END IF;
END;
/
OEF
Otr:
#!/bin/sh
# convertor_file_baruta.sh Version 2.0
# by Freddy R. Jáuregui R.
getlocation()
{
sqlplus -s sis/sis@rac << EOF
set heading off
set verify off
set feed off
set linesize 1024
set pagesize 0
select lpad(a.codigo_estado_cta_fiscal,2,0)||
lpad(a.codigo_municipio_cta_fiscal,2,0)
from sis_empresas a
where a.codigo_empresa = $1;
EOF
}
clear
echo "
*************************** Convertor File Baruta ****************************
********************************************************************************
"
echo -n "Input file name: "; read file_source
directory_source="/u3/samiweb/tmp/file_baruta/"
bank=`echo ${file_source} | cut -c2-4`
directory_target="/u3/samiweb/tmp/file_baruta/bank_${bank}/sami/"
directory_target_old="/u3/samiweb/tmp/file_baruta/bank_${bank}/informix/"
[ -f ${directory_source}${file_source} ] || {
echo "No such file or directory ${directory_source}${file_source}"
exit 1
}
[ -d ${directory_target} ] || {
echo "No such directory ${directory_target}"
exit 1
}
file_target=`echo ${file_source} | \
/usr/bin/awk '{
printf("%s%s%s%s%s",
substr($0,2,3),substr($0,11,2),substr($0,9,2),substr($0,5,4),substr($0,13,7))
}' 2> /dev/null`
sequence1=`echo ${file_target} | cut -c1-11`
sequence=`echo ${file_target} | cut -c1-11`
list=`ls -r ${directory_target}${sequence}* 2> /dev/null`
for file in ${list}
{
x=`echo ${file} | cut -c54-56`
x=`expr ${x} + 1`
[ ${x} -lt 10 ] && x="00"${x} || x="0"${x}
sequence=`echo ${sequence} | cut -c1-11`${x}".txt"
break
}
[ $sequence = $sequence1 ] && sequence=`echo ${sequence} | cut -c1-11`"001.txt"
file_target=${sequence}
echo -en "\nGenerating File ${file_target}..."
error_awk=0
/usr/bin/awk '{
if ( NR == 1 )
lr = length($0);
else
{
if ( lr != length($0) )
{
print "\nFile Invalidate.\n" > "/dev/stderr";
'error_awk=1';
exit;
}
};
if ( substr($0,13,2) == "04" )
{
datafield = substr($0,15,6);
command = "./convertor_file_baruta_sql.sh "substr($0,13,2)" "datafield" 1";
command | getline field;
if ( field == "no_data_found" )
{
command = "./convertor_file_baruta_sql.sh "substr($0,13,2)" "datafield" 2";
command | getline field;
}
printf("%s%s%s%s%s%s%s%s\n",
substr($0,0,3),
substr($0,59,8),
"'`getlocation 7`'",
field,
"0",
substr($0,67,13),
"0",
substr($0,4,9));
}
else
datafield = substr($0,21,9);
}' ${directory_source}${file_source} > ${directory_target}${file_target}
[ ${error_awk} -eq 1 ] &&
rm -f ${directory_target}${file_target} ||
mv ${directory_source}${file_source} ${directory_target_old}${file_source}
echo -e "Done"
exit 0
--------
otr mas:
este hasta notifica con emails a las cuentas de usuario que se configuren_
#!/bin/sh
# export.sh - version: 1.0
# Script para exportar bases de datos ORACLE
#
[ $# -eq 1 ] || {
echo "Usage: $0 ORACLE_SID"; exit 2
}
# Set up the Oracle variables:
ORACLE_BASE=/home/oracle/app; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/9i; export ORACLE_HOME
export ORACLE_SID=$1
# Set up the Oracle Lenguage variables:
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
# Set up the search paths:
export PATH=$PATH:$ORACLE_HOME/bin:/usr/bin:/usr/lib:/$ORACLE_HOME/lib
# Set up the local variables and Export directory:
dir_sid=`echo ${ORACLE_SID}|tr A-Z a-z`
dir_exp=/u3/exports/${dir_sid}
gzip=/bin/gzip
hecho()
{
mail oracle <<!
$*
!
}
error()
{
mail oracle <<!
$*
!
exit 1
}
. /home/oracle/.profile
cd ${dir_exp}
for userpasswd in `cat ../.userpasswd`
do
user=`echo ${userpasswd}|cut -d/ -f1`
exp ${userpasswd} \
FILE=${dir_exp}/${user}.dmp \
FEEDBACK=50000 \
LOG=${dir_exp}/${user}.log
$gzip ${dir_exp}/${user}.dmp || error "${user}.dmp.gz Can't Create"
$gzip ${dir_exp}/${user}.log || error "${user}.log.gz Can't Create"
done
cd ..
fecha=`date +'%Y%m%d%H%M'`
/bin/tar cvf ${dir_exp}/${ORACLE_SID}_${fecha}.tar ${dir_sid}/*.gz &&
hecho "${ORACLE_SID}_${fecha}.tar Created" ||
error "${ORACLE_SID}_${fecha}.tar Can't Create"
# Remove temporary files
rm -f ${dir_exp}/*.dmp ${dir_exp}/*.log ${dir_exp}/*.gz
# EOF

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas