Sponsored Content
Top Forums Shell Programming and Scripting Bash interactive installation script Post 302396776 by Softsmid on Friday 19th of February 2010 09:13:45 AM
Old 02-19-2010
Bash interactive installation script

Hi, for an exercise I need to write a script that will ask the user about each package in a (local) repository and install it or not according to the user's input.

I am fairly new to scripting, so I did not get very far. Here is what I came up with. I really appreciate your help.

Code:
#!/bin/bash 
#Checks if you are root or not 
if test "`id -u`" -ne 0
	then 
	echo "You need to run this script as root!" 
	exit 
fi
#here needs to start a loop that lists all the packages like dpkg -l does one for one and
#asks for user input. I got as far as the code below. But the script does not stop yet to ask
#after every file, any suggestions?
for pkg in `dpkg -l`
do
	echo Found package: $pkg
done
		echo "Do you wish to install $pkg ?"
		select yn in "Yes" "No"
		do
		    case $yn in
		        Yes ) apt-get -d install $apl; break;;
		        No ) exit;;
		    esac
		done
	# continue...


Last edited by Softsmid; 02-19-2010 at 11:28 AM.. Reason: code tags, please...
 

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Help with Interactive / Non Interactive Shell script

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (1 Reply)
Discussion started by: rits
1 Replies

2. Homework & Coursework Questions

How to write script that behaves both in interactive and non interactive mode

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (8 Replies)
Discussion started by: rits
8 Replies

3. Shell Programming and Scripting

Execute interactive bash menu script in browser with PHP

I have an interactive menu script written in bash and I would like use PHP to open the interactive bash menu in a browser. Is this possible? Using the sytem() function in php runs the script but it's all garbled. Seems like maybe a terminal window needs to be opened in php first? ... (1 Reply)
Discussion started by: nck
1 Replies

4. Solaris

New interactive installation

I just took delivery of an Ultra Sparc 60 box. I tried to install Solaris 10 from the cdrom by issuing the following command at ok prompt: ok boot cdrom, and I am getting an error message that says: "Boot device: /pci@1f,4000/scsi@3/disk@6,0:f File and args: can't open boot device. What am I... (2 Replies)
Discussion started by: ijeoma
2 Replies

5. Debian

Bash script to STOP installation 'if' a file exists...

Hey all, Here's my dilemma: 1. I'm a newbie at scripting! 2. I need to create a script that checks: If a file size is equal to zero, then stop the installation. Is there a way to do this or am I wasting my time??? Thanx in advance! :b: (2 Replies)
Discussion started by: thazsar
2 Replies

6. Shell Programming and Scripting

Non interactive su in bash script

Hi, I have a python gui which allow users entering the root password, then a bash script is called to run "su" with the root password on the background. I could find a way to run "su" with a password. How to run "su" in a bash script without password prompt? Thank you. (4 Replies)
Discussion started by: hce
4 Replies

7. Shell Programming and Scripting

Creating an Interactive Bash Script to Analyze a PCAP

Hello Everyone, I am currently trying to write a Bash Script to call a PCAP file. The command I will use in the script will be the following: tshark -r test.pcap -T fields -e frame.number -e frame.time -e eth.src -e eth.dst -e ip.src -e ip.dst -r ip.proto -E header=y -E separator=, quote=d -E... (4 Replies)
Discussion started by: MrTuxor
4 Replies

8. Shell Programming and Scripting

Passing arguments to interactive program through bash script, here document

Dear Users, I have installed a standalone program to do multiple sequence alignment which takes user parameters to run the program. I have multiple sequence files and want to automate this process through a bash script. I have tried to write a small bash code but its throwing errors. Kindly... (13 Replies)
Discussion started by: biochemist
13 Replies

9. Shell Programming and Scripting

Bash interactive Script Required

Dear All, Please help in creating a bash script to fetch records from multiple files the script should ask inputs of file type and column level input(at least 4 col of each file type) I have 4 sort of Files, A,B,C,D. file names are like A_0112.unl, A_01215.unl, A_0001.unl and same with B C... (3 Replies)
Discussion started by: Muhammad Ali
3 Replies

10. Shell Programming and Scripting

Bash -c interactive scripts

i have to run the following script through a pipe: script.sh: #!/bin/bash echo "Hello World" echo -e "The \033 here's how its currently being run: bash -c "$(cat script.sh)" This is an interactive script. the problem is, when i run it this way, if you go to another terminal and... (4 Replies)
Discussion started by: SkySmart
4 Replies
APT-MARK(8)								APT							       APT-MARK(8)

NAME
apt-mark - show, set and unset various settings for a package SYNOPSIS
apt-mark {-f=filename | {auto | manual} pkg... | {showauto | showmanual} [pkg...] } | {-v | --version} | {-h | --help} apt-mark {hold | unhold | install | remove | purge} pkg... | {showhold | showinstall | showremove | showpurge} [pkg...] DESCRIPTION
apt-mark can be used as a unified front-end to set various settings for a package, such as marking a package as being automatically/manually installed or changing dpkg selections such as hold, install, deinstall and purge which are respected e.g. by apt-get dselect-upgrade or aptitude. AUTOMATICALLY AND MANUALLY INSTALLED PACKAGES
When you request that a package is installed, and as a result other packages are installed to satisfy its dependencies, the dependencies are marked as being automatically installed, while the package you installed explicitly is marked as manually installed. Once an automatically installed package is no longer depended on by any manually installed package it is considered no longer needed and e.g. apt-get or aptitude will at least suggest removing them. auto auto is used to mark a package as being automatically installed, which will cause the package to be removed when no more manually installed packages depend on this package. manual manual is used to mark a package as being manually installed, which will prevent the package from being automatically removed if no other packages depend on it. showauto showauto is used to print a list of automatically installed packages with each package on a new line. All automatically installed packages will be listed if no package is given. If packages are given only those which are automatically installed will be shown. showmanual showmanual can be used in the same way as showauto except that it will print a list of manually installed packages instead. Options -f=filename, --file=filename Read/Write package stats from the filename given with the parameter filename instead of from the default location, which is extended_status in the directory defined by the Configuration Item: Dir::State. PREVENT CHANGES FOR A PACKAGE
hold hold is used to mark a package as held back, which will prevent the package from being automatically installed, upgraded or removed. unhold unhold is used to cancel a previously set hold on a package to allow all actions again. showhold showhold is used to print a list of packages on hold in the same way as for the other show commands. SCHEDULE PACKAGES FOR INSTALL, REMOVE AND PURGE Some front-ends like apt-get dselect-upgrade can be used to apply previously scheduled changes to the install state of packages. Such changes can be scheduled with the install, remove (also known as deinstall) and purge commands. Packages with a specific selection can be displayed with showinstall, showremove and showpurge respectively. More information about these so called dpkg selections can be found in dpkg(1). OPTIONS
-h, --help Show a short usage summary. -v, --version Show the program version. -c, --config-file Configuration File; Specify a configuration file to use. The program will read the default configuration file and then this configuration file. If configuration settings need to be set before the default configuration files are parsed specify a file with the APT_CONFIG environment variable. See apt.conf(5) for syntax information. -o, --option Set a Configuration Option; This will set an arbitrary configuration option. The syntax is -o Foo::Bar=bar. -o and --option can be used multiple times to set different options. FILES
/var/lib/apt/extended_states Status list of auto-installed packages. Configuration Item: Dir::State::extended_states. SEE ALSO
apt-get(8),aptitude(8),apt.conf(5) DIAGNOSTICS
apt-mark returns zero on normal operation, non-zero on error. BUGS
APT bug page[1]. If you wish to report a bug in APT, please see /usr/share/doc/debian/bug-reporting.txt or the reportbug(1) command. AUTHORS
Mike O'Connor APT team NOTES
1. APT bug page http://bugs.debian.org/src:apt APT 1.6.3ubuntu0.1 25 September 2015 APT-MARK(8)
All times are GMT -4. The time now is 10:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy