的zenity --info对话是不稳定 [英] zenity --info dialog is unstable

查看:208
本文介绍了的zenity --info对话是不稳定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个随机生成的密码的脚本,我已经修改了它使用的zenity 在GUI中显示。当我使用原来的剧本,我可以产生用户选择任意长度的随机密码(我拥有50000测试)。这里的code:

I have a script that randomly generates passwords, I have modified it to display in a GUI using zenity. When I use the original script, I can produce random passwords of any length the user chooses (I tested with 50,000). Here's the code :

    #!/bin/bash
    number=10
    echo "hello"
    echo "Please enter your number: $number"
    read newnumber
    # read newnumber
    [ -n "$newnumber" ] && number=$newnumber

    MATRIX="0123456789<?/_+-!@#$%^&*>ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
    #  Password will consist of standard characters.
    LENGTH=$newnumber
    #This variable can be changed for password lenth (need to try get zenity to let user choose that number)


    while [ "${n:=1}" -le "$LENGTH" ]
    # := is "default substitution" operator.
    # So, if 'n' has not been initialized, set it to 1.
   do
   PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
    # Very clever, but tricky.

    # Starting from the innermost nesting...
    # ${#MATRIX} returns length of array MATRIX.

    # $RANDOM%${#MATRIX} returns random number between 1
    # and [length of MATRIX] - 1.

    # ${MATRIX:$(($RANDOM%${#MATRIX})):1}
    # returns expansion of MATRIX at random position, by length 1. 
    # See {var:pos:len} parameter substitution in Chapter 9.
    # and the associated examples.

    # PASS=... simply pastes this result onto previous PASS (concatenation).

    # to let zenity show the password being built one character at a time, uncomment the following line
            # zenity --info --text="$PASS"
    let n+=1
    # Increment 'n' for next pass.
    done

    echo "$PASS"

(我从后面的[另一个问题] [1]

(I have followed on from [another question][1]

[1]:<一href=\"http://stackoverflow.com/questions/25508386/using-a-variable-as-another-variable-in-a-bash-script\">Using一个变量在bash脚本另一个变量?)

我的问题是,现在是,当试图产生更高的长度的密码他们不会在的zenity --info 对话框中显示,任何超过30击中或错过。我已完成了通过反复运行脚本,每次但它不够好选择60到如此漫无,9次了10年它会产生少于20个字符,显示60字符和斗争更加越高长度它具有产生。但只有在的zenity

My problem is now that when try produce higher length passwords they wont display in the zenity --info dialog box, anything over 30 is hit or miss. I have got it to display a 60 character by repeatedly running the script and choosing 60 each time but its not good enough to be so hit or miss, 9 times out of 10 it will produce less than 20 characters and struggles more the higher the length it has to generate. But only in zenity

任何帮助当然是极大的AP preciated的。

Any help is of course greatly appreciated.

推荐答案

我已经找到了答案,它是烦人简单...字符&LT; / @#&放大器; * 将导致的zenity使用时发生崩溃,但没有人知道为什么吗?

I have found the answer and it's annoyingly simple... the characters </@#&* would cause the generator to crash when used with zenity, but does anyone know why?

这篇关于的zenity --info对话是不稳定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆