You are not logged in.
Pages: 1
OK i want to create a shell script to put in /sbin so that when i want to get packages via pacman i can run the script and then it will give me an area to type in. When i type the package(s) i want it to do a
sudo pacman -Sy X Y Z
(where X Y & Z are package names). I want to do this more for personal reasons and not really for functionallity......can anyone give me any building blocks/links of things i should start with?
~HP ZV6000 Series CTO~
-AMD Athlon 64 3200+ 2.0GHz
-1.5GB RAM
-128MB ATI Mobility Radeon X200m
-80GB 5400RPM HD
[img]http://imagegen.last.fm/scarface/recenttracks/mtrivs.gif[/img]
Offline
Nevermind...I searched through several sites and found most of the information myself... Here is what i came up with:
#!/bin/sh
echo "Please input the name of the package you want"
read ans
clear
echo "Downloading and installing packages!"
sudo pacman -Sy --noconfirm $ans
~HP ZV6000 Series CTO~
-AMD Athlon 64 3200+ 2.0GHz
-1.5GB RAM
-128MB ATI Mobility Radeon X200m
-80GB 5400RPM HD
[img]http://imagegen.last.fm/scarface/recenttracks/mtrivs.gif[/img]
Offline
I found some more info and developed this (changed it so that if a user enters "x", "q", "exit", or "none", then the script exits!!!!
!/bin/sh
echo "Please input the name of the package you want"
read ans
if [ $ans = "exit" ] || [ $ans = "none" ] || [ $ans = "q" ] || [ $ans = "x" ]
then
exit
else
echo "Downloading and installing packages!"
sudo pacman -Sy --noconfirm $ans
fi
Shell scripting is great!!!!
~HP ZV6000 Series CTO~
-AMD Athlon 64 3200+ 2.0GHz
-1.5GB RAM
-128MB ATI Mobility Radeon X200m
-80GB 5400RPM HD
[img]http://imagegen.last.fm/scarface/recenttracks/mtrivs.gif[/img]
Offline
ok from my last post i showed you my shell script, but when i type in more than one package it gives me the following error:
/sbin/pak: line 6: [: too many arguments
/sbin/pak: line 6: [: too many arguments
/sbin/pak: line 6: [: too many arguments
/sbin/pak: line 6: [: too many arguments
How can i either fix this or supress this?
~HP ZV6000 Series CTO~
-AMD Athlon 64 3200+ 2.0GHz
-1.5GB RAM
-128MB ATI Mobility Radeon X200m
-80GB 5400RPM HD
[img]http://imagegen.last.fm/scarface/recenttracks/mtrivs.gif[/img]
Offline
put it in a for loop
Offline
I know what a for loop is, but where would i put that in....could someone show me an example?
Thanks!
~HP ZV6000 Series CTO~
-AMD Athlon 64 3200+ 2.0GHz
-1.5GB RAM
-128MB ATI Mobility Radeon X200m
-80GB 5400RPM HD
[img]http://imagegen.last.fm/scarface/recenttracks/mtrivs.gif[/img]
Offline
replace this:
if [ $ans = "exit" ] || [ $ans = "none" ] || [ $ans = "q" ] || [ $ans = "x" ]
with that:
if [ "$ans" = "exit" -o "$ans" = "none" -o "$ans" = "q" -o "$ans" = "x" ]
PS. loop is not needed
Offline
#!/bin/sh
echo "Please input the name of the package(s) you want:"
read ans
if [ "$ans" = "exit" -o "$ans" = "none" -o "$ans" = "q" -o "$ans" = "x" -o "$ans" = "close"]
then
exit
elif [ $ans = "all" ]
then
echo "Full system upgrade!"
sudo pacman -Syu
elif [ $ans = "s" ]
then
echo "Please enter the name of the package you would like to search for"
read ans1
if [ "$ans1" = "exit" -o "$ans1" = "none" -o "$ans1" = "q" -o "$ans1" = "x" -o "$ans" = "close" ]
then
exit
else
sudo pacman -Ss $ans1
fi
else
echo "Downloading and installing the packages you requested!"
sudo pacman -Sy $ans
fi
OK i changed the if statement, but i still get one of these:
/sbin/pak: line 9: [: too many arguments
~HP ZV6000 Series CTO~
-AMD Athlon 64 3200+ 2.0GHz
-1.5GB RAM
-128MB ATI Mobility Radeon X200m
-80GB 5400RPM HD
[img]http://imagegen.last.fm/scarface/recenttracks/mtrivs.gif[/img]
Offline
Wouldnt it be easer to add
alias pacget = "sudo pacman -Sy"
to your .bashrc, and just type pacget X Y Z ?
Instead of trying to reinvent the wheel, I mean.
Although if you do this to learn shellscripting, it's a good way to go ;-)
Offline
Yea i am just trying to learn shell scripts, im not really planning on using this program....
~HP ZV6000 Series CTO~
-AMD Athlon 64 3200+ 2.0GHz
-1.5GB RAM
-128MB ATI Mobility Radeon X200m
-80GB 5400RPM HD
[img]http://imagegen.last.fm/scarface/recenttracks/mtrivs.gif[/img]
Offline
You may want to put a confirmation request for the whole upgrade all command.
Writing stories for a machine.
Offline
2 questions:
1. what does a confirmation do?
2. how would i implement it into the script?
Thanks for the help guys!!!
~HP ZV6000 Series CTO~
-AMD Athlon 64 3200+ 2.0GHz
-1.5GB RAM
-128MB ATI Mobility Radeon X200m
-80GB 5400RPM HD
[img]http://imagegen.last.fm/scarface/recenttracks/mtrivs.gif[/img]
Offline
A confirmation statement like:
Upgrading ENTIRE system. Ok to procede(y/n)?_
Dunnos sh but the basic premise is:
define function prompt_for_command(command)
prompt "which packages to install"
if command == "all"
prompt "upgrading entire system. ok to procede(y/n)? "
if y
run pacman commands
else
prompt_for_command()
Personally I'd put in a confirmation for all commands, to ensure you're running what you want to run and isntalling what you want.
Writing stories for a machine.
Offline
OK i changed the if statement, but i still get one of these:
/sbin/pak: line 9: [: too many arguments
Whenever you're comparing $ans to strings, put quotes around it.
elif [ $ans = "all" ]
...
elif [ $ans = "s" ]
should be
elif [ "$ans" = "all" ]
...
elif [ "$ans" = "s" ]
The reason for this is it automatically expands $ans. If you put in more than one package, then
$ans = X Y Z
and the test becomes
elif [ X Y Z = "all" ]
and, as you can see, it has no idea how to decide what to do with that, since X Y and Z are not in quotes.
Offline
Pages: 1