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";

Bartcore3 2011-05-29 10:16

Re: Scripting Help Required - DPKG
 
so you should always start with this?
Like saying to your N900, here comes a shell script :p
K thanks ;)

kingoddball 2011-05-29 10:25

Re: Scripting Help Required - DPKG
 
I belibe so.
To start the script on Linux/N900 terminal:
Code:

./scriptname or if it fails . ./scriptname
After you make your script you will need to change the chmod

Type chmod 755 yourscriptname
Ch chmod +x scriptname

A simple script

#!/bin/sh
echo "hello. This is pretty cool"


That's it.

vi_ 2011-05-29 10:57

Re: Scripting Help Required - DPKG
 
Quote:

Originally Posted by Bartcore3 (Post 1017863)
what does this mean?
Code:

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

From your avatar, I cannot tell if you are trollin' or not...

The line essentially tells the computer which interpreter to run the script in.

In the above example you are telling the computer to use the interpreter which is called 'sh'. sh is the 'shell'.

you could say:

Code:

#!/bin/bash
That would mean run this script IN bash. You could say:

Code:

#!/bin/python
That would mean run this script IN python.


Kingoddball:

My signature is a hilarious joke that apparently makes you a total bastard when you tell it.

My signature is a script that randomly chooses a number between 6 and 0, if you get a 0 it runs another script called a 'fork bomb' that crashes your computer. If you get between 1-6 it prints 'you live' and does nothing. It is computer russian roulette.

It used to delete everything on your computer if you got 0 but a bunch of people started crying about how mean that is so I changed it at Jedi's suggestion.


PS, dont run my signature

Bartcore3 2011-05-29 21:47

Re: Scripting Help Required - DPKG
 
Quote:

Originally Posted by vi_ (Post 1017894)
From your avatar, I cannot tell if you are trollin' or not...

i can assure you that i'm not a troll, i just like the IE trollface :)


All times are GMT. The time now is 08:14.

vBulletin® Version 3.8.8