You are not logged in.
Hi All,
I have a script to update a git version of a software, but I would like to be able to check the output of the script in a terminal.
So in a nut shell, I want when launching the script:
- Terminal to Open
- All command to be executed in the terminal
- Terminal to close only if no error (do not know if it's possible?)
See below my very simple script:
Many thanks in advance for your time and advice,
rm -r /home/sweetth/banshee &&
cd /home/sweetth &&
git clone git://git.gnome.org/banshee &&
cd /home/sweetth/banshee &&
./autogen.sh &&
make
Offline
'xterm -e <command>' opens xterm and executes <command>
I think $? returns zero if no errors.
Offline
karol is right yo ucan use xterm.
To specify it that you want to run more than one command you can use the weak quotes: " "
Example :
xterm -e "echo hello; echo This is the second command"
However the terminal will close as soon as your commands are finished. What you could do is to use a sleep at the end if your last command worked with a || like
make || sleep 50
which would run the sleep only if make fails.
You could also cat the output of your commands to only display the error (that means print nothing if no error).
Last edited by jiehong (2010-09-25 13:30:49)
Offline
The question is, why do you need the terminal in the first place? You can execute the script and check the logs and make it do sth if it fails - send an a-mail etc.
The '-hold' option will keep the xterm window open, whether the command executed fails or not:
xterm -hold -e "echo hello; echo This is the second command"
Last edited by karol (2010-09-25 13:50:44)
Offline
You could also use the script command.
Offline
#!/bin/bash
echo ta-da
echo
if [ "$?" -eq 0 ]; then
echo Good job!
else
echo You failed!
fi
read -p "Press ENTER to close window."
echo
Run 'xterm -e <name_of_the_script>' and see if it's better than the '-hold' option.
Offline
Many thanks for the reply,
I have now work on the script a lot more, it goes fetch some PKGBUILD from AUR to create some pkg (update quite regularly), but I am trying to make my script install/update those pkg via "gksudo pacman -U nameofpkg" but it return an error of wrong argument with gksudo "-U"
any idea?
Offline
try using the -i argument to makepkg instead
Offline
the issue is not to make those pkg but to install them, see command in script below:
cd ~/libpod &&
gksudo pacman -U gtk-sharp-beans-git** gio-sharp-git** gkeyfile-sharp-git** gudev-sharp-git** libgpod-sharp-git**
Offline
Have you tired any AUR helpers?
Offline
I do not have an issue making those pkg, I want to install them via script
Offline
I do not have an issue making those pkg, I want to install them via script
try using the -i argument to makepkg instead
sweetthdevil, what is wrong with this approach? Where does it fail?
Offline
see output terminal while running those commands.
[sweetth@myhost ~]$ cd ~/libpod &&
> gksudo pacman -U gtk-sharp-beans-git** gio-sharp-git** gkeyfile-sharp-git** gudev-sharp-git** libgpod-sharp-git**
gksudo: invalid option -- 'U'
GKsu version 2.0.2
And this is where I have the issue,
Offline
cd /var/cache/pacman/pkg && sudo pacman -U xulrunner**
I have no problem running sudo.
Offline
yes, but this in a script and need GKsudo to prompt for the password
Offline
yes, but this in a script and need GKsudo to prompt for the password
I don't follow, if it's a script don't you want it non-interactive, just fire and forget? With the correct entries in sudoers file you won't be prompted for password.
Have a look at gksudo man page.
Offline
Right, I manage it differently
So I got my script to dl those PKGBUILD for those Ipod library needed for the latest Banshee, then dl the latest banshee git and "make" it.
for those who might be interested to keep their banshee-git update:
#!/bin/bash
xterm -hold -e "mkdir ~/libpod;
cd ~/libpod;
mkdir ~/libpod/gtk-sharp-beans-git
cd ~/libpod/gtk-sharp-beans-git
wget http://aur.archlinux.org/packages/gtk-sharp-beans-git/gtk-sharp-beans-git/PKGBUILD;
wget http://aur.archlinux.org/packages/gtk-sharp-beans-git/gtk-sharp-beans-git/autogen_fix.patch;
makepkg -s;
mv gtk-sharp-beans-git** ~/libpod;
cd ~/libpod;
rm -rf ~/libpod/gtk-sharp-beans-git;
mkdir ~/libpod/gio-sharp-git;
cd ~/libpod/gio-sharp-git;
wget http://aur.archlinux.org/packages/gio-sharp-git/gio-sharp-git/PKGBUILD;
makepkg -s;
mv gio-sharp-git** ~/libpod;
cd ~/libpod;
rm -rf ~/libpod/gio-sharp-git;
mkdir ~/libpod/gkeyfile-sharp-git;
cd ~/libpod/gkeyfile-sharp-git;
wget http://aur.archlinux.org/packages/gkeyfile-sharp-git/gkeyfile-sharp-git/PKGBUILD;
makepkg -s;
mv gkeyfile-sharp-git** ~/libpod;
cd ~/libpod;
rm -rf ~/libpod/gkeyfile-sharp-git;
mkdir ~/libpod/gudev-sharp-git;
cd ~/libpod/gudev-sharp-git;
wget http://aur.archlinux.org/packages/gudev-sharp-git/gudev-sharp-git/PKGBUILD;
makepkg -s;
mv gudev-sharp-git** ~/libpod;
cd ~/libpod;
rm -rf ~/libpod/gudev-sharp-git;
mkdir ~/libpod/libpod-sharp-git;
cd ~/libpod/libpod-sharp-git;
wget http://aur.archlinux.org/packages/libgpod-sharp-git/libgpod-sharp-git/PKGBUILD;
makepkg -s;
mv libgpod-sharp-git** ~/libpod;
rm -rf ~/libpod/libpod-sharp-git;
cd ~/libpod;
sudo pacman -U gtk-sharp-beans-git** gio-sharp-git** gkeyfile-sharp-git** gudev-sharp-git** libgpod-sharp-git**;
rm -rf ~/banshee;
cd ~;
git clone git://git.gnome.org/banshee;
cd ~/banshee;
./autogen.sh;
make;
rm bin/Banshee.NotificationArea.dll*"
Offline
Glad you got it working, but I still don't get you don't you use 'makepkg -si'.
Offline
Well because I do not want to set up sudo to work without password, so like that I have the script asking me once for the password in xterm window
Offline
Well because I do not want to set up sudo to work without password, so like that I have the script asking me once for the password in xterm window
I'm guessing you want to enter the password just once and not for every package, right? You can see if '--noconfirm' option for makepkg helps.
If you don't want to build in /tmp you can try this:
#!/bin/bash
# scriptname: bansheebuild
downloads="/home/karol/test_down"
apps="/home/karol/build_dir"
mkdir $downloads
mkdir $apps
for i in uzbl-git screen-git; do
#for i in banshee-git gtk-sharp-beans-git gio-sharp-git gkeyfile-sharp-git gudev-sharp-git libgpod-sharp-git; do
cd $downloads
wget http://aur.archlinux.org/packages/$i/$i.tar.gz
bsdtar xf $i.tar.gz -C $apps && cd $apps/$i && makepkg -si --noconfirm PKGBUILD
done
rm -rf $downloads $apps
Adjust the folder paths and the packages you want to build and install. I've tested it on uzbl-git and screen-git.
Tarballs from AUR are downloaded to $downloads and extracted to $apps, where the sources are downloaded and built.
The last line removes both directories with all that was inside.
You can add the banshee part and run the whole script with
xterm -hold -e /path/to/bansheebuild
Why aren't you using http://aur.archlinux.org/packages.php?ID=26048 ?
Offline