You are not logged in.

#1 2005-11-09 04:21:43

CyberTron
Member
From: Gotland ,Sweden
Registered: 2005-03-17
Posts: 645
Website

dialog/bash gurus please help me!

Hi

I am having this problem with some lines of code,

i am trying to make a "menu" with the help of dialog --checklist

and I know how to make this the normal way by doing

dialog --backtitle "E17_Buildscript" --title "Choose files" 
        --checklist "Choose which files from e17-libs you wantnn
Which files" 30 61 6 
        "eet"  "It's an apple." on 
        "edb"    "No, that's not my dog." ON 
        "evas" "Yeah, that's juicy." on 2> /tmp/checklist2.tmp.$$

but I wanna do this is an textfile,

so I created a text file that is:

lib/eet-cvs
lib/edb-cvs
e17/e-cvs

and so on

and created a code for it:

select_install()
{
    dodialog msgbox "In the next stage you are going to choose which packages to install, recommendation is that you install all packages." 18 70
    CHKLIST=
    if [ "$MODE" = "install" ]; then
        PKGS=$PKGS_PATH
    fi

    for app in `sed 's|"||g' $PKGS | awk '{ print $1 }'`; do
        CHKLIST="$CHKLIST $app INSTALL ON"
    done
    
    if [ -e /tmp/.pkglist ]; then 
    rm /tmp/.pkglist
    fi

    domenu checklist "Select Packages" 19 55 12 $CHKLIST 2>/tmp/.pkglist || return 1
        
    if [ $? == 0 ]; then
    install
    else
    mainmenu
    fi
}

This code snippet works, almost perfect, it is only that, I wanna change the line CHKLIST="$CHKLIST $app INSTALL ON"

to CHKLIST="$CHKLIST $app $DESCRIPTION ON"

to get the text in lib/eet-cvs   to become > lib   (using sed I assume) and then getting dialog to use it together with eet-cvs
so the list should look like

[x]     eet-cvs     lib
[x]     edb-cvs   lib
[x]     e-cvs       e17

Is there anyone who knows what I could do? I have spent 24hours just staring and testing different solutions, and the only solution that even comes close is to use: CHKLIST="$CHKLIST $app $app ON"     and that is not correct , if I use other things I get something like:

[x]     eet-cvs    edb-cvs
[x]     e-cvs       lib
[x]     lib          lib
[x]    lib           lib


http://www.linuxportalen.com  -> Linux Help portal for Linux and ArchLinux (in swedish)

Dell Inspiron 8500
Kernel 2.6.14-archck1  (selfcompiled)
Enlightenment 17

Offline

#2 2005-11-09 11:54:55

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: dialog/bash gurus please help me!

grep "$CHKLIST $app INSTALL ON" name_of_CTsFile | sed 's|INSTALL|$DESCRIPTION|'

will replace that line a print to standard out without altering the file. If you want to insert it into a file append -i /path/to/file at the end of the sed statement.

Offline

#3 2005-11-09 12:34:08

CyberTron
Member
From: Gotland ,Sweden
Registered: 2005-03-17
Posts: 645
Website

Re: dialog/bash gurus please help me!

Do I understand correctly

PKGS=/home/cybertron/pkg.list
DESCRIPTION=/home/cybertron/gui/description.list
    for app in `sed 's|"||g' $PKGS | awk '{ print $1 }'`; do
        CHKLIST=`grep "$CHKLIST $app INSTALL ON" $PKGS | sed 's|INSTALL|$DESCRIPTION|'`
    done

doesn't seem to work....I guess I am thinking wrong


http://www.linuxportalen.com  -> Linux Help portal for Linux and ArchLinux (in swedish)

Dell Inspiron 8500
Kernel 2.6.14-archck1  (selfcompiled)
Enlightenment 17

Offline

#4 2005-11-09 12:50:31

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: dialog/bash gurus please help me!

I guess I don't understand either.

This code snippet works, almost perfect, it is only that, I wanna change the line CHKLIST="$CHKLIST $app INSTALL ON"

to CHKLIST="$CHKLIST $app $DESCRIPTION ON"

I thought you wanted that line in your program replaced. If so, the file to grep is not $PKG but /usr/bin/whatever you called it.
Could you re-clarify?

Offline

#5 2005-11-09 13:03:34

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: dialog/bash gurus please help me!

I think, he's got a text file with

lib/eet-cvs
lib/edb-cvs
e17/e-cvs

and he wants to extract the part before the '/' on every line to use as $DESCRIPTION, and the part after the '/' to be stored in $app, so that when he uses

CHKLIST="$CHKLIST $app $DESCRIPTION ON"

The first line is
[x] eet-cvs lib

And so on... I think he wants help modifying the script he posted to do that.

Too bad I don't know how.  tongue

Offline

#6 2005-11-09 14:26:08

CyberTron
Member
From: Gotland ,Sweden
Registered: 2005-03-17
Posts: 645
Website

Re: dialog/bash gurus please help me!

Thanks cerebral, that is exactly what I want, sorry for not making myself clear enough...it is quite hard..

Penguin: Is this possible?
and if so, do you know how?


http://www.linuxportalen.com  -> Linux Help portal for Linux and ArchLinux (in swedish)

Dell Inspiron 8500
Kernel 2.6.14-archck1  (selfcompiled)
Enlightenment 17

Offline

#7 2005-11-09 16:00:57

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: dialog/bash gurus please help me!

PKGS=/home/cybertron/pkg.list 
ct=0

for i in `cat $PKG`; do
     CHKLIST[$ct]=`echo $i |awk -F/ {'print $1'}
     app[$ct]=`echo $i |awk -F/ {'print $2'}
     ct=$(($ct+1))
done

unset ct

that will set everything on the left of the "/" to $CHKLIST and everything from the right as $app assuming $PKG is the file with all the revelant lines in it. Now, if you do something like echo ${CHKLIST[@]} or echo ${app[@]} it will display everything from the left of the "/" and the right "/" as an entire array. Maybe you could plug that into your checklist gui line to show all the options from that file?

HTH

Offline

#8 2005-11-09 16:22:07

CyberTron
Member
From: Gotland ,Sweden
Registered: 2005-03-17
Posts: 645
Website

Re: dialog/bash gurus please help me!

hmmm..gives about the same errors I have gotten before, it sorts it somehow wrong...it might be a limitation of dialog perhaps....


this code give me:

[ ]  eet-cvs edb-cvs
[ ]  evas-cvs e-cvs
[ ] lib    lib
[ ] e17  e17

ct=0

for i in `cat $PKGS`; do
     description[$ct]=`echo $i |awk -F/ {'print $1'}`
     app[$ct]=`echo $i |awk -F/ {'print $2'}`
     ct=$(($ct+1))
done

unset ct
	
		CHKLIST="${CHKLIST} ${app[@]} ${description[@]} ON"

but then again, the real command for doing this is:

ialog --backtitle "E17_Buildscript" --title "Choose files" 
        --checklist "Choose which files from e17-libs you wantnn
Which files" 30 61 6 
        "eet"  "It's an apple." on 
        "edb"    "No, that's not my dog." ON 
        "evas" "Yeah, that's juicy." on 2> /tmp/checklist2.tmp.$$

[/code]


http://www.linuxportalen.com  -> Linux Help portal for Linux and ArchLinux (in swedish)

Dell Inspiron 8500
Kernel 2.6.14-archck1  (selfcompiled)
Enlightenment 17

Offline

#9 2005-11-09 17:51:59

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: dialog/bash gurus please help me!

Heh, NOW I can help.

for i in `cat $PKGS`; do
     description=`echo $i |awk -F/ {'print $1'}`
     app=`echo $i |awk -F/ {'print $2'}`
     CHKLIST="${CHKLIST} ${app} ${description} ON"
done

Offline

#10 2005-11-09 18:07:35

CyberTron
Member
From: Gotland ,Sweden
Registered: 2005-03-17
Posts: 645
Website

Re: dialog/bash gurus please help me!

OH MY GOD!! IT IS WORKING!!!!

THANK YOU BOTH SOO MUCH!!!!

big_smile

*i am so lucky...I can finally finish my program*


http://www.linuxportalen.com  -> Linux Help portal for Linux and ArchLinux (in swedish)

Dell Inspiron 8500
Kernel 2.6.14-archck1  (selfcompiled)
Enlightenment 17

Offline

#11 2005-11-10 08:31:51

Legout
Member
From: Wuerburg/germany
Registered: 2004-01-19
Posts: 292

Re: dialog/bash gurus please help me!

Seems that yu are writing a script fr installing e17. Am I right?

Can u tell more about it? When will it be finished?

Legout

Offline

#12 2005-11-10 08:39:11

CyberTron
Member
From: Gotland ,Sweden
Registered: 2005-03-17
Posts: 645
Website

Re: dialog/bash gurus please help me!

yes it is in alpha, it is working, you can check in either the user-contributions forum or the e17-thread in the desktop environment thread

there are links to a workable script there..

i am now going to clean up the script and do some modifications to what is going to happen when a package fails

have fun, and please try it out and report any errors


http://www.linuxportalen.com  -> Linux Help portal for Linux and ArchLinux (in swedish)

Dell Inspiron 8500
Kernel 2.6.14-archck1  (selfcompiled)
Enlightenment 17

Offline

Board footer

Powered by FluxBB