[SOLVED] Word count script for medit - help troubleshoot please
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I presume you are a member of bbs.archlinux.org, I think you should post this there asking ConnorBehan for help. I don't see why this problem is related to using Debian instead of Arch. Even if it is, the author may be interested in making the add on more universal.
What Google, especially Google Linux, searches have you done?
I just installed medit-0.9.2 which is the latest Debian package available to me in SimplyMEPIS 8.0, including python & zenity. Which ver. of medit are you using? I ask because I can't find the "Settings > Preferences > Tools" mentioned in the wiki article you linked to. So I don't know how to install this add on.
I think this line in the output is the key to your problem (it was red, after all ):
Code:
/bin/sh: Bad substitution
I ran the following test in a Konsole (KDE's console):
Because my true shell is bash, "/bin/sh" is bash in sh mode; it is not necessarily a perfect simulation. However, it looks to me like that distinction is not the problem.
HTH, at least you know someone has looked at your post.
Last edited by archtoad6; 04-29-2011 at 07:10 AM.
Reason: give a better test example
I also just installed the Debian package version of medit to test this out, and was very frustrated because it completely failed to install any of the documentation that was supposed to come with it (no info or help pages; only the man page, which gives no useful info about scripting).
So I downloaded the newest medit package and extracted it's help files, and I think I worked it out.
The problem with the above is that the $DOC variable holds the current file name. But if the document hasn't been saved yet, then there's no file for it to work on, so you get empty variables.
Apparently the newest versions of medit have a new input item called "Document Copy", which makes a temporary duplicate of the file for the script to work on. If your install has that option, then switching to it, and changing every instance of "DOC" to "INPUT_FILE", should make it work.
Since Debian's version doesn't have that yet, I improvised a different solution. Since the other input options all feed to stdin, I modified the script like so:
Since Debian's version doesn't have that yet, I improvised a different solution. Since the other input options all feed to stdin, I modified the script like so:
Thanks David. I tried this, and got the error:
Code:
/bin/sh: Syntax error: redirection unexpected
*** Exited with status 2 ***
(When output is changed to pane - otherwise nothing visible
happened.)
But it's good to know that the original code works in a newer version of medit, so I can wait for that if necessary.
I presume you are a member of bbs.archlinux.org, I think you should post this there asking ConnorBehan for help. I don't see why this problem is related to using Debian instead of Arch. Even if it is, the author may be interested in making the add on more universal.
What Google, especially Google Linux, searches have you done?
archtoad6, I'm not a member of bbs.archlinux.org - I discovered that page through Google. I find that asking about a problem on platform X on a platform Y forum doesn't always get popular reactions, so here seemed more appropriate.
It works for me. Perhaps yours isn't using bash to interpret the script? I used bash-specific here strings above.
I wonder if adding a #!/bin/bash shebang as the first line will work?
Or try replacing the wc lines with a more portable version. e.g.
Code:
bytes=$( echo "$input" | wc -c )
Eidt: After a bit of testing, it looks like the medit script interface ignores shebang settings. But I'm convinced now that you're system is using dash as the shell; I get the same error when I switch to it. So just change the wc lines as above and I'm sure it will work.
Last edited by David the H.; 05-01-2011 at 03:02 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.