LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-08-2016, 07:31 AM   #1
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,620
Blog Entries: 40

Rep: Reputation: Disabled
YAD (ex zenity) front-end for mcrypt and mdecrypt


Please tell me your opinion about this script on pastebin :

http://pastebin.com/aq9FW97f

I have been considering writing more of these script front-ends for Zenity and Yad and could not decide for any real task. File-encryption finally gives me enough inspiration to try out all those nifty controls.

Runs with YAD 0.33.1 (GTK+ 3.18.6), but probably also with previous versions.

Cheerio,

Michael

Last edited by Michael Uplawski; 02-08-2016 at 07:39 AM.
 
Old 02-08-2016, 09:55 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
I was intrigued by zenity/yad in the beginning.
But for day-to-day stuff, it's not for me "for any real task".

zenity/yad is "cute" but in the end, I'd only write something for end users.

Your script comments look good and are plentiful and well-placed.

Erm...
# Remove pre-existing files if we are about to replace them anyway.

Should that happen after the encrypt?
 
1 members found this post helpful.
Old 02-09-2016, 03:55 AM   #3
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,620

Original Poster
Blog Entries: 40

Rep: Reputation: Disabled
Hi.

Thank you for the comment. YAD is just there to be used or not. What I do is basically avoid the command-line for mcrypt where I sometimes forget options and have to repeat my actions.

Quote:
Originally Posted by Habitual View Post
zenity/yad is "cute" but in the end, I'd only write something for end users.
Right. But the options, even for YAD are many and the frugal task to create a GUI around a script will be a chore, when you first have to work out all the details. As for the exercise, mcrypt asked for some digging into the syntax for YAD and I also had to make the resulting values palatable to mcrypt. This is a new way to write shell-scripts for me. I cannot say that I were shell-guru and believe that it shows anyway.

Quote:
# Remove pre-existing files if we are about to replace them anyway.
Should that happen after the encrypt?
There are two use-cases: remove the encrypted file, before writing a new one and remove the decrypted file, prior decrypting again. My impression is that both work with the current script. This way, I avoid the program asking for the user's decision.

No, but what I was really aiming for (not with YAD but) with this thread was your comments on mcrypt and the possible uses. I admit, that I could have been more specific but the question is not really clear to myself...

The information that something is wrong with mcrypt does not satisfy me and having my problems with gpg2 -c or crypting stuff with OpenSSL, mcrypt is still my utility of choice. I never understood the problem, nor if the library or only the executable program was affected. I have an encrypted partition, but admit that I have almost or actually no use for it. Moving encrypted files around is much more interesting for me than to store them for good and possibly destroy them all at once, in case of (what?) emergency...

In conclusion, if mcrypt is useable and nice, my YAD script might ... make it even better, I guess.., or something.

Last edited by Michael Uplawski; 02-09-2016 at 04:02 AM.
 
Old 02-09-2016, 03:48 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Code:
 yad --image "dialog-error" --title "ERROR" --text="$FILE is not a valid file for $ACTIONion! Aborting."
You need braces around the $ACTION variable, like this:
Code:
 yad --image "dialog-error" --title "ERROR" --text="$FILE is not a valid file for ${ACTION}ion! Aborting."
Otherwise it would look for a variable called "ACTIONion".

Code:
# find the default algorithm and mark it
# with '^' for yad
AL=''
for i in `seq 0 50`
do
    if [ ${ALGOS[$i]} != ' ' ]
    then
        a=${ALGOS[$i]}
        if [ "$DEF_ALGO" == $a ]
        then
            a="^$a"
        fi
        AL="$a $AL"
    else
        break
    fi
done
I think it's equivalent to:
Code:
AL=${ALGOS[*]/$DEF_ALGO/^$DEF_ALGO}
Shell Parameter Expansion:
Quote:
${parameter/pattern/string}

The pattern is expanded to produce a pattern just as in filename expansion. Parameter is expanded and the longest match of pattern against its value is replaced with string. If pattern begins with ‘/’, all matches of pattern are replaced with string. Normally only the first match is replaced. If pattern begins with ‘#’, it must match at the beginning of the expanded value of parameter. If pattern begins with ‘%’, it must match at the end of the expanded value of parameter. If string is null, matches of pattern are deleted and the / following pattern may be omitted. If parameter is ‘@’ or ‘*’, the substitution operation is applied to each positional parameter in turn, and the expansion is the resultant list. If parameter is an array variable subscripted with ‘@’ or ‘*’, the substitution operation is applied to each member of the array in turn, and the expansion is the resultant list.
 
1 members found this post helpful.
Old 02-10-2016, 12:26 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
mcrypt and mdecrypt may be related to security but your initial post is not. To make your thread get the attention it deserves I've moved it to the Linux General forum. Have fun!
 
Old 02-12-2016, 06:43 AM   #6
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,620

Original Poster
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by unSpawn View Post
mcrypt and mdecrypt may be related to security but your initial post is not. To make your thread get the attention it deserves I've moved it to the Linux General forum. Have fun!
I am sorry for the late response, but access to the Internet is a disaster in some areas of France, in 2016.
@unSpawn: Okay, I will have to open another thread on mcrypt (alone) in the security-forum, as the question still bugs me. [Done. New thread: mcrypt, what is the problem?]

@ntubski:
Code:
AL=${ALGOS[*]/$DEF_ALGO/^$DEF_ALGO}
Looks very nice. The man page has served me often enough, but I would not have known how to look for this detail. Most “discoveries” I make by accident, or because people tell me explicitly (I have carved three notches in oak- and fir-wood today, and they fit!). ;-)

Last edited by Michael Uplawski; 02-12-2016 at 08:08 AM. Reason: link to new thread about mcrypt
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Myth TV back end or front end. thedoctor Linux - Newbie 1 05-20-2010 07:58 PM
gui read out of back end command lines from gui front end activation? how? Siljrath Linux - General 0 10-24-2008 10:11 AM
Mythbuntu front-end and back-end questions... Liambiscuit Linux - Software 4 09-28-2008 05:11 PM
Multiple Apache - Front-end & Back-end in one server grant-skywalker Linux - Server 3 08-27-2008 02:04 PM
after a web front end acid_kewpie Linux - Networking 1 08-15-2002 05:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration