Automate Script using pkgrm/pkgadd commands


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Automate Script using pkgrm/pkgadd commands
# 8  
Old 09-24-2008
I think you got it wrong.

You write a simple file with the answers in the order you like them:

cat infile:
Code:
y
n
n
y
all
n
y

Then you just call your command like I posted before:
Code:
pkgrm somesoftware < infile

Quote:
"yes | pkgrm [package-name]"
This won't work anyway, there is an "echo" missing in front of "yes".
# 9  
Old 09-24-2008
I think you got it wrong Smilie

I need to use both pkgrm and pkgadd. pkgrm works fine if i use
yes | pkgrm $PACKAGE (without echo)

The problem is with the pkgadd because the first answer should be 'all' and the second 'y'. Not all the answers are yes otherwise the above trick would work for pkgadd as well. I also tried using an input file with :

all
y

but it doesn't work. If you read my previous post again you will understand. Any other help?
# 10  
Old 09-24-2008
Sadly I don't have those tools available - yes, maybe someone else will help you, good luck ^^
# 11  
Old 09-24-2008
Quote:
Originally Posted by zaxxon
Sadly I don't have those tools available
Just to clarify: "yes" (/usr/bin/yes) is a tool which produces streams of "y^M" (a "y" followed by a newline). AIX has it as any other Unix derivate i am aware of.

I suspect the reason why pkgadd does not work with an input redirection is because it clears the input channel before reading the second input. This is meant as a security device (to avoid answers which in fact are just accidentally doubly typed keys from the last answer) but is in fact puting an obstacle in using the tool in any pipeline or pipeline-like construct. This is plain bad programming style of the i-have-not-understood-Unix-concepts category.

Aside from feeling sympathetically with you i fear there is no solution to this problem. pkgadd is simply programmed badly on your system.

I hope this helps.

bakunin
# 12  
Old 09-25-2008
That "yes" tool I did not know, yep. But I meant that I don't have those pkgadd and pkgrm tools available etc.
# 13  
Old 09-25-2008
The brute-force solution would be to write a simple expect script. It's not a tool I particularly like but it sounds right for this problem.
# 14  
Old 09-26-2008
I finally found the solution to this problem by doing a simple 'trick'.

pkgadd has an -a option which allows to use your own admin file to control the process. The format of this file is similar to the one below.

instance=overwrite
partial=nocheck
runlevel=nocheck
idepend=nocheck
rdepend=nocheck
space=nocheck
setuid=nocheck
conflict=nocheck
action=nocheck
basedir=default

The 'action=nocheck' line tells to the command to bypass the questions in order to automate the execution.

The problem is that the first question which needs an 'all' answer (instead of 'y') cannot be bypassed by this command.

What I did was to create two files. The first one had the above 'admin file' structure and the second one had only one line with the word 'all'.

echo "mail=
instance=overwrite
partial=nocheck
runlevel=nocheck
idepend=nocheck
rdepend=nocheck
space=nocheck
setuid=nocheck
conflict=nocheck
action=nocheck
basedir=default" > $NOASK_FILE

echo "all" > $INPUT_FILE


By using the following command:


pkgadd -a $NOASK_FILE -d [package-path] < $INPUT_FILE

the package was added automatically without any user interaction.

I hope this helps others that will face the same issue in the future.

Thanks for your replies.
This User Gave Thanks to Insight For This Post:
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