The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script(s) to Automate Tasks droppedonjapan Shell Programming and Scripting 2 05-21-2008 07:32 AM
script to automate mksysb via nim in AIX 5.3 barkath Shell Programming and Scripting 0 12-20-2007 03:46 PM
here document to automate perl script that call script hogger84 Shell Programming and Scripting 3 10-22-2007 07:15 AM
pkgrm XNOR UNIX for Dummies Questions & Answers 7 04-06-2007 04:04 PM
automate the input in a script erwinspeybroeck UNIX for Dummies Questions & Answers 11 01-31-2002 07:54 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-24-2008
Registered User
 

Join Date: Sep 2008
Posts: 5
Automate Script using pkgrm/pkgadd commands

This is my first post so hello to all of you!

I have a script in bash-3.00 that needs to execute the following:

pkgrm [package-name] (to remove an existing package)
pkgadd -d [package-path] ( to install a new package)

The problem is that both commands prompt me to answer either y,n or q in order to proceed with removal/addition 3 times each. If I just run the command I will have to type 'y' and press Enter 3 times (for pkgrm) and type 'all' one time and 'y' two times both followed by Enter (for pkgadd).

I tried to automate this using the following:

echo "Removing existing package..."
pkgrm $PACKAGE << EOF
y
y
y
EOF

echo "Adding new package..."
pkgadd -d $PATH/$PACKAGE.pkg << EOF
all
y
y
EOF

but it's not working. In fact only the first input line works (first 'y' for pkgrm and 'all' for pkgadd) and then the command exits as If I had typed 'q'.

Can anyone help me on this? Is there any way that I can automate this so that I won't have to answer the questions manually?

Thanks,

Insight
Reply With Quote
Forum Sponsor
  #2  
Old 09-24-2008
Moderator
 

Join Date: Sep 2007
Location: Germany
Posts: 1,031
Maybe this helps:

Code:
man pkgrm
Quote:
OPTIONS
-n Non-interactive mode. If there is a need for
interaction, the command will exit. Use of this
option requires that at least one package instance
be named upon invocation of the command.
Reply With Quote
  #3  
Old 09-24-2008
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,262
Quote:
Originally Posted by zaxxon View Post
I don't know from which OS these package handling tools are,
These are the original System V software management tools. Most of the Unix systems understand them. The "-n" you mentioned should be commonplace.

I hope this helps.

bakunin
Reply With Quote
  #4  
Old 09-24-2008
Moderator
 

Join Date: Sep 2007
Location: Germany
Posts: 1,031
A native installed Debian Linux or an AIX doesn't. Found it with Solaris man pages though. Thanks for the hint
Reply With Quote
  #5  
Old 09-24-2008
Registered User
 

Join Date: Sep 2008
Posts: 5
I tried using the -n option but this only bypasses the first question which is:

"Do you want to remove this package? [y,n,?,q]"

-n just automates this question and after that I get the second one along with the error message:

"This package contains scripts which will be executed with super-user
permission during the process of removing this package.
Removal of <new_package> was suspended (interaction required)."

and the script terminates.

If I don't use -n then the second prompt is:

"This package contains scripts which will be executed with super-user
permission during the process of removing this package.
Do you want to continue with the removal of this package [y,n,?,q]
Removal of <new_package> failed.
No changes were made to the system." (looks like I typed 'n' or 'q')

Any other suggestions?
Reply With Quote
  #6  
Old 09-24-2008
Moderator
 

Join Date: Sep 2007
Location: Germany
Posts: 1,031
Just found this:

Solaris 9 Discussion - How to remove automatically packages?

They are using this answerfile not as a here-script but just as an input file by redirecting it like

Code:
pkgrm somesoftware < infile
Reply With Quote
  #7  
Old 09-24-2008
Registered User
 

Join Date: Sep 2008
Posts: 5
I checked the link you sent me.

The pkgrm works fine if I use "yes | pkgrm [package-name]" because all the answers should be 'y'.

However pkgadd doesn't work because the first answer should be 'all' and the second 'y'. I tried using an input file as the topic in the link suggests by having:

bash-3.00$ cat input
all
y
bash-3.00$

but it doesn't work. I tried using a combination of " yes | ..." and an input file but it doesn't work as well.

Any ideas?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0