1

I'm trying to make a download manager with dialog, but I can't display download history (function view_history) with infobox.

Error: Expected no more than 3 tokens for --infobox, have 5.
Use --help to list options.

My other question:

I can make it work with cat $HOME/dmlog.txt but since my script has many clear commands, I can't see the cat command output without scrolling. Any ideas how can I do that? I've tried sleep command after it but it looks like poor design.

1 Answer 1

0

--tailbox file height width Display text from a file in a dialog box, as in a "tail -f" command...

Use a textbox for showing text files and scrolling.

--textbox file height width A text box lets you display the contents of a text file in a dialog box. It is like a simple text file viewer. The user can move through the file by using the cursor, page-up, page-down and HOME/END keys available on most keyboards. If the lines are too long to be displayed in the box, the LEFT/RIGHT keys can be used to scroll the text region horizontally...

documentation: https://linux.die.net/man/1/dialog

TextboxDialog() {
dialog "Example" --textbox "/PathTo/File.txt" 20 50
}

And you got some issues using your function. Your forgot the () and also quote the File Path in ""

So your function should look like:

function view_history() {
    dialog --textbox "$HOME/dmlog.txt" $HEIGHT $WIDTH
}


If you want to show some information to the user, display the information in a msgbox or infobox. You can control which menu should start after user interaction.

You can call another action after your message was shown with eval.

${NextMenu} calls the function you want. Where the variable $NextMenu stores the name of your function.

     InfoDialog(){

    MenuName="$1"
    InfoText="$2"
    NextMenu="$3"
    dialog --no-cancel --title "$MenuName" --msgbox "$InfoText" 20 50
    ${NextMenu}
}

The same with Yes/No Dialogs, for maybe controlling something:

YesNoDialog() {

    MenuName="$1"
    InfoText="$2"
    NextMenu="$3"
    dialog --yes-label "OK" --no-label "STOP" --defaultno --title "$MenuName" --yesno "$InfoText" 20 50
    answer=$?
    if [ $answer = 0 ]
    then            
        ${NextMenu}
    else
        MainMenu
    fi      
}   

Rember to set your overgiven variables outsite a function, and call your function with the variables. Example:

InfoDialog(){

    MenuName="$1"
    InfoText="$2"
    NextMenu="$3"
    dialog --no-cancel --title "$MenuName" --msgbox "$InfoText" 20 50
    ${NextMenu}
}

MenuName="$1"
InfoText="$2"
NextMenu="$3"
InfoErrorDialog $MenuName $InfoText $NextMenu**

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .