Bash

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Magnuss
    New Member
    • Jun 2007
    • 2

    Bash

    Hello

    I am trying to learn bash, and have found Xdialog to make them look better. But when I was experimenting with this code I couldn't get it to work.

    Code:
    #!/bin/bash
    
    numfiles=1;
    dump='--title "XDIALOG BUILDLIST" --backtitle "A user-built list" \ --stdout --clear --separator "|" --buildlist "hello, this is a --buildlist..." 0 0 6 ';
    
    function addfile {
    	FILE=`Xdialog --title "Please choose a file" --fselect /home 28 48`;
    
    	case $? in
    		0)
    			FILES[${numfiles}]="$FILE";
    			numfiles=$numfiles+1;
    			addfile;;
    		1)
    			foonum=$numfiles;
    			for ((i=1;i<$foonum;i++)); do 
    			  dump+="\ \"${i}\" \"${FILES[${i}]}\" \"off\" ";
    			done;;
    		255)
    			echo "Box closed";;
    	esac
    }
    
    addfile
    
    
    result=`Xdialog $dump`;
    
    retval=$?
    case $retval in
      0)
        echo "The user-built list is '$result'.";;
      1)
        echo "Cancel pressed '$result'.";;
      255)
        echo "Box closed '$result'.";;
    esac
    What I want to do is to let the user choose several files, and then export it to a buildlist. But it gives me an erro and shows the helpfile:
    "Xdialog: missing list parameters !"

    Any help is appreciated!
  • arne
    Recognized Expert Contributor
    • Oct 2006
    • 315

    #2
    Originally posted by Magnuss
    Hello

    I am trying to learn bash, and have found Xdialog to make them look better. But when I was experimenting with this code I couldn't get it to work.

    Code:
    #!/bin/bash
    
    numfiles=1;
    dump='--title "XDIALOG BUILDLIST" --backtitle "A user-built list" \ --stdout --clear --separator "|" --buildlist "hello, this is a --buildlist..." 0 0 6 ';
    
    function addfile {
    	FILE=`Xdialog --title "Please choose a file" --fselect /home 28 48`;
    
    	case $? indialog --title "Please choose a file" --fselect /tmp 0 0
    		0)
    			FILES[${numfiles}]="$FILE";
    			numfiles=$numfiles+1;
    			addfile;;
    		1)
    			foonum=$numfiles;
    			for ((i=1;i<$foonum;i++)); do 
    			  dump+="\ \"${i}\" \"${FILES[${i}]}\" \"off\" ";
    			done;;
    		255)
    			echo "Box closed";;
    	esac
    }
    
    addfile
    
    
    result=`Xdialog $dump`;
    dialog --title "Please choose a file" --fselect /tmp 0 0
    retval=$?
    case $retval in
      0)
        echo "The user-built list is '$result'.";;
      1)
        echo "Cancel pressed '$result'.";;
      255)
        echo "Box closed '$result'.";;
    esac
    dialog --title "Please choose a file" --fselect /tmp 0 0

    What I want to do is to let the user choose several files, and then export it to a buildlist. But it gives me an erro and shows the helpfile:
    "Xdialog: missing list parameters !"

    Any help is appreciated!

    Did you try to run your Xdialog commands directly from the command line (instead of from within a script)? This looks like an XDialog usage error rather than a bash scripting problem.

    arne

    Comment

    • Magnuss
      New Member
      • Jun 2007
      • 2

      #3
      I tried within the script only. However, I have tried to make it print out the code which is generating the buildlist and entered it directly into the terminal, and it worked.

      I just went over to Zenity, which seems easier to me, and much more logical. So thanks for the help, but I don't need more help on Xdialog now :)

      Comment

      • arne
        Recognized Expert Contributor
        • Oct 2006
        • 315

        #4
        Originally posted by Magnuss
        I tried within the script only. However, I have tried to make it print out the code which is generating the buildlist and entered it directly into the terminal, and it worked.

        I just went over to Zenity, which seems easier to me, and much more logical. So thanks for the help, but I don't need more help on Xdialog now :)
        Ok, no problem. Never heard about Zenity ... you never stop learning :)

        arne

        Comment

        Working...