Automate Script using pkgrm/pkgadd commands


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Automate Script using pkgrm/pkgadd commands
# 1  
Old 09-24-2008
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
# 2  
Old 09-24-2008
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.
# 3  
Old 09-24-2008
Quote:
Originally Posted by zaxxon
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
# 4  
Old 09-24-2008
A native installed Debian Linux or an AIX doesn't. Found it with Solaris man pages though. Thanks for the hint Smilie
# 5  
Old 09-24-2008
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?
# 6  
Old 09-24-2008
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

# 7  
Old 09-24-2008
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Open Source

Help with writing Shell Script to automate process using multiple commands

Hello! Need help to write a Linux script that can be run from windows using command/Cygwin/any other way. I am new to scripting, actually i am trying to automate server health check like free disk space, memory along with few services status, if any services is not running then start services ,... (7 Replies)
Discussion started by: Sayed Ibrahim
7 Replies

2. Shell Programming and Scripting

Automate multiple commands

Hi, I am trying to count the number of times a string of letters occurs in a file for multiple unique strings of letters. Right now I can do this one at a time using the following code (in this example I am searching for the string "AAA"): echo AAA >> outfile.txt grep -c "AAA" -r... (4 Replies)
Discussion started by: gecko1
4 Replies

3. Shell Programming and Scripting

Need Help with commands to automate.

HI, In some test cases, I used tools like "dd" and "shed" to manually read a block from the disk, modify it using a hex editor and write it back using "dd". I need help with some linux commands I can use to read the block and change the data to induce the corruption....as I want to automate my... (3 Replies)
Discussion started by: prinsh
3 Replies

4. Windows & DOS: Issues & Discussions

automate the script

Dear all, I I want to login to my Linux machine using putty and then run some script from Windows machine.we can do it after loging it and then execute the script by typing it in putty command line screen. but I want to automate it.So whenever I will fire this script,it will do the following... (4 Replies)
Discussion started by: smartgupta
4 Replies

5. Shell Programming and Scripting

Automate remote script

Hi all, I need to execute a script on a remote machine that are connected to the network.The basic requirement is to write a script which will login in remote machine and then execute the other script automatically placed in remote machine.So that I need to execute the remote machine script... (3 Replies)
Discussion started by: smartgupta
3 Replies

6. Shell Programming and Scripting

How can I automate a script?

Hi All, Can I automate a script when some one trying to 'vi' (open) a file. For Example, I am having a file named 'SecuredShell.sh'. when a user types " vi SecuredShell.sh " in unix command prompt a script named secure.sh needs to be automated. Can this be possible. if Yes please guide... (2 Replies)
Discussion started by: little_wonder
2 Replies

7. UNIX for Advanced & Expert Users

Shell Script to Automate

I would like to automate script where i do not have to manually insert the username and password I wrote two different scripts but not able to achieve the results: here's to scripts i wrote #!/bin/bash cd /var/tmp /home/server/steve/pca --askauth -idx /opt/app/bin/expect <<EOF expect... (1 Reply)
Discussion started by: sam786
1 Replies

8. Solaris

pkgrm without removing the dependent packages

Hi all, Is there any option to remove a package without removing the dependent packages.... ie, i need to remove a package, while trying to remove by using pkgrm command it says as some dependent packages also will get removed, i dont want to remove those dependent packages. (1 Reply)
Discussion started by: judi
1 Replies

9. Shell Programming and Scripting

here document to automate perl script that call script

I am trying to use a here document to automate testing a perl script however when the perl script hits a system(perl subscript.pl) call, input is no longer entered into this subscript. here is my script $ cat test.sh #ksh for testcase do program <<-EOF | tee -a funcscnlog.log y... (3 Replies)
Discussion started by: hogger84
3 Replies

10. UNIX for Dummies Questions & Answers

pkgrm

Hello, How can I list the installed packages on my Solaris 10 ? Regards :confused: (7 Replies)
Discussion started by: XNOR
7 Replies
Login or Register to Ask a Question