maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Scripting Help Required - DPKG (https://talk.maemo.org/showthread.php?t=73560)

kingoddball 2011-05-29 08:52

Scripting Help Required - DPKG
 
Hello!!

I need a little help with scripting.

I want to install a .DEB from a script (4 in totoal).

I had the idea, but did not go right..

Essentially I want this:

(located in MyDocs)

Code:

#!/bin/sh

cd /specified-folder/


sudo dpkg -i genericprogram-name_test.deb

sudo dpkg -i genericprogram-name1_modules.deb

sudo dpkg -i generic_program-name2_special.deb

sudo dpkg -i generic_program-name3.deb

This spits out a bunch of errors saying --help and such. Nothing of help.

I use dpgk -i to install these *.deb files normally. Please help. :o

vi_ 2011-05-29 08:57

Re: Scripting Help Required - DPKG
 
Quote:

Originally Posted by kingoddball (Post 1017829)
Hello!!

I need a little help with scripting.

I want to install a .DEB from a script (4 in totoal).

I had the idea, but did not go right..

Essentially I want this:

(located in MyDocs)

Code:

#!/bin/sh

cd /specified-folder/


sudo dpkg -i genericprogram-name_test.deb

sudo dpkg -i genericprogram-name1_modules.deb

sudo dpkg -i generic_program-name2_special.deb

sudo dpkg -i generic_program-name3.deb


Code:

#!/bin/sh
cd /specified-folder/

echo "dpkg -i *.deb" | root

echo "job done!"


kingoddball 2011-05-29 08:58

Re: Scripting Help Required - DPKG
 
You're a hero! You come out of nowhere and save the day! AGAIN! :D

vi_ 2011-05-29 09:07

Re: Scripting Help Required - DPKG
 
Quote:

Originally Posted by kingoddball (Post 1017833)
You're a hero! You come out of nowhere and save the day! AGAIN! :D

NP breh, What is more important is you understand the script so that in the future you will be better at writing 'em.

Code:

#!/bin/sh
cd /specified-folder/

You clearly know what that stuff is.



Code:

echo "dpkg -i *.deb" | root
Here we use the pipe '|' it is a special unix character that essentialy allows us to direct the output of a program to another program. In this example, the 'echo' command simply echos whatever parameter you give it. In this case 'dpkg -i *.deb'. This string is enclosed in quotes so the echo program knows it is a single string.

So echo echos that string back to us, we then use pipe to direct that string to the program root. (root is of course 'root shell', the land of sudo.)

So in essence we have:

SAY 'dpkg -i *.deb' TO root



Code:

echo "job done!"
echos 'job done' to the current shell, as we are working on the current shell we see job done!

comprende?

kingoddball 2011-05-29 09:12

Re: Scripting Help Required - DPKG
 
Unfortunately this keep throwing errors.

Using the same as you posted:
dpkg: error processing *.deb (--install): cannot access archive: No such file or directory. Errors encounered while processing: *.deb (I have also added the start of the filename).

When I do it using the full filename:
Error is:

./script
line 6: syntax error: "|" unextected

Edit: If I remove the pipe | all it does is echo the words :(

I am doing all this on the N900 if thats any different.

vi_ 2011-05-29 09:18

Re: Scripting Help Required - DPKG
 
oopz

As the *.deb is in the quotes it is being treated as a literal string as opposed to a globbed expression.

Replace the line with:

Code:

sudo dpkg -i *.deb
So much for trying to show off huh?

vi_ 2011-05-29 09:19

Re: Scripting Help Required - DPKG
 
Code:

#!/bin/sh
sudo apt-get install kernel-power
cd wl1251-maemo/binary/kernel-power/
sudo dpkg -i *.deb

Will install ALL .deb in that directory.

kingoddball 2011-05-29 10:00

Re: Scripting Help Required - DPKG
 
You're excellent!
I used the one you said that will install all. It worked perfectly!
But what would I do to install.. Maybe 2 only.

Just seems odd that it failed to install one using the same method.

Also: VI_ what does your signature mean/do....

Bartcore3 2011-05-29 10:08

Re: Scripting Help Required - DPKG
 
what does this mean?
Code:

#!/bin/sh
i'm planning to learn all this when i finish my exams ^^

kingoddball 2011-05-29 10:10

Re: Scripting Help Required - DPKG
 
Shell script.
You can also use #!/bin/bash

I'm not sure what it fully means in the Linux terminology, the way I know it " this is a script";


All times are GMT. The time now is 12:09.

vBulletin® Version 3.8.8