Sponsored Content
Top Forums Shell Programming and Scripting how to combine two scripts into one Post 302425136 by ggoliath on Thursday 27th of May 2010 08:32:40 AM
Old 05-27-2010
how to combine two scripts into one

I need to combine two scripts, into one script. One is to delete something, the to recreate. Here is the scripts:
Code:
BIN=/usr/lbin
LINE='device for 0101a01: lpd://172.25.41.111:515'
while read LINE
do
prt=`echo $LINE | awk '{print $3 }'| cut -c 1-7`
echo $prt
#drv=`echo $LINE | awk -F":" '{print $2}'`
#echo $drv
#IP=`echo $LINE | awk -F"/" '{print $3}' | cut -d":" -f1`
#echo $IP
#port=`echo $LINE | awk -F":" '{print $4}'`
#echo $port
  if [ "${prt}" = "0117bd1" ]; then
     echo "\n\t Deleting printer $prt  !!!"
     $BIN/lpadmin -x ${prt} 2> /dev/null
  fi
done < diffs.txt

recreate statement:
Code:
#!/bin/ksh -xv
BIN=/usr/lbin
LINE='device for 0101a01: lpd://172.25.41.111:515'
while read LINE
do
prt=`echo $LINE | awk '{print $3 }' | cut -c 1-7`
echo $prt
drv=`echo $LINE | awk -F":" '{print $2}'`
echo $drv
IP=`echo $LINE | awk -F"/" '{print $3}' | cut -d":" -f1`
echo $IP
port=`echo $LINE | awk -F":" '{print $4}'`
echo $port
  if [ "${prt}" = "0117bd1" ]; then
        echo " Adding printer $prt !!!!"
        $BIN/lpadmin -p ${prt} -E -v ${drv}://${IP}:${port}
        echo " Printer $prt:$drv:$IP:$port added!!!!"
  fi
done< diffs.txt

The variables are the same...the text file has three printers that need to be deleted and recreated...
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

i want to combine two awk scripts which is having same loop and filelist

hi, to all give me some idea below scripts file=`cat filelist` for filename in $file do awk '{ if ($0 ~ /system/ && flag == 0) { flag=1; print $0; } else if ($0 ~ /system/ && flag == 1) { printf("%s SYSLAY %s %s %s\n",$1,$3, $4, $5); } else print $0; }' $filename >... (6 Replies)
Discussion started by: LAKSHMI NARAYAN
6 Replies

2. UNIX for Dummies Questions & Answers

Profile scripts versus rc scripts....

what is the difference between login and profile scripts versus the rc scripts? (1 Reply)
Discussion started by: rookie22
1 Replies

3. Shell Programming and Scripting

help with a script that will combine two separate scripts for solaris and aix

Hello experts, I have separate scripts (KSH) each for Solaris and AIX to install core applications (e.g. BigBrother). I also have a script called Installer that gives a menu list to select a particular application to install from a bunch of applications. Now I am trying to combine separate... (7 Replies)
Discussion started by: solaix14
7 Replies

4. Shell Programming and Scripting

Help with Script using rsh and scripts within scripts

Hi, I've written a script that runs on a Database server. It has to shutdown the Application server, do an Oracle Dump and then restart the Application server. Its been a long time since I wrote any shells scripts. Can you tell me if the scripts that I execute within my script will be executed... (3 Replies)
Discussion started by: brockwile1
3 Replies

5. Shell Programming and Scripting

Running scripts within scripts from cron

Hi all, I have set up a cron job which calls another shell script shell script which in turn calls a Java process. The cron tab looks so. 0,30 7-18 * * 1-5 /u01/home/weblogic/brp/bin/checkstatus.sh >> /u01/home/weblogic/logs/checkstatus.log The checkstatus.sh scripts looks like this. ... (4 Replies)
Discussion started by: sirbrian
4 Replies

6. Shell Programming and Scripting

Changing the Bash Scripts to Bourne Scripts:URGENT

Hi, I have to write a program to compute the checksums of files ./script.sh I wrote the program using bash and it took me forever since I am a beginner but it works very well. I'm getting so close to the deadline and I realised today that actually I have to use normal Bourne shell... (3 Replies)
Discussion started by: pgarg1989
3 Replies

7. Shell Programming and Scripting

KSH - How to call different scripts from master scripts based on a column in an Oracle table

Dear Members, I have a table REQUESTS in Oracle which has an attribute REQUEST_ACTION. The entries in REQUEST_ACTION are like, ME, MD, ND, NE etc. I would like to create a script which will will call other scripts based on the request action. Can we directly read from the REQUEST_ACTION... (2 Replies)
Discussion started by: Yoodit
2 Replies

8. Shell Programming and Scripting

Calling multiple scripts from another scripts

Dear all, I am working on script which call other shell scripts in a loop but problem is from second script am not able to come out. Here is the snippet:- #!/bin/bash HSFILE=/root/Test/Components.txt LOGFile=/opt/domain/AdminDomain/application/logs... (3 Replies)
Discussion started by: sharsour
3 Replies

9. UNIX for Beginners Questions & Answers

Combine awk scripts

Hi, Below command is working as expected, but would like to know how to club the two AWK scripts in the command into one echo -e "MMS000101S0203430A|20180412E|\nMMB0001INVESTMENT||107-86193-01-03|\nMMB0001FUND||107-86193-04-01|\nMMC9991 " | awk -F'|' -v OFS=, '/^MMC9991/{print r"|"s,t; next}... (3 Replies)
Discussion started by: JSKOBS
3 Replies
NAUTILUS-SCRIPTS-MANAGER(1)				      General Commands Manual				       NAUTILUS-SCRIPTS-MANAGER(1)

NAME
nautilus-scripts-manager - easy tool for nautilus scripts management SYNOPSIS
nautilus-scripts-manager [options] DESCRIPTION
This manual page documents briefly the nautilus-scripts-manager command. nautilus-scripts-manager is a program that allows any user to easily manage installed Nautilus scripts. GENERAL OPTIONS
-h, --help Show summary of options. -v, --version Show version of program. COMMANDS
One (and only one) of the following commands can be passed: -e, --enable=ENABLE Enable script ENABLE. -d, --disable=DISABLE Disable script DISABLE. -l, --list-enabled List enabled scripts. -a, --list-available List available scripts. If no command is provided, the graphical interface is started. OPTIONS
-e, --position=POSITION In conjunction with -e or -d: establish the position of the script (can be just a name, or a path with slashes - quote it if it con- tains spaces). SEE ALSO
nautilus(1), AUTHOR
nautilus-scripts-manager and this manual page were written by Pietro Battiston <me@pietrobattiston.it>. This manual page was written for the Debian project (but may be used by others). July 14, 2009 NAUTILUS-SCRIPTS-MANAGER(1)
All times are GMT -4. The time now is 12:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy