Yours answers suggested me that the shortcomming of my script was not given by its code line /usr/bin/mc but by the fact that the whole script has been launched under an X session, not under a true shell session (meanwhile I did check and can say the script does work as expected under a true shell session). So I would restate my problem as follows. How to modify the following script

Code:

#!/bin/bash/usr/bin/mcexit

to the effect for it of being effective when launched under an X session?

No, mc is simply the well known Midnight Commander in my case and I do not intend to get any taskbar or desktop link to it but simply test the launch of a sample script (as a script beginner). Unfortunately I'm now writing from my office therefore I could not verify I certain guess on my desktop at home. After some googling, I guess the Kwrite editor (which I have used to edit the script) could be resposible for the disorder (I mean the Kwrite's implementation of the new line character). I intend to rewrite the same script by Nano (instead of Kwrite) and see what happens. Any way, several other people encountered similar problems under Windows, because of the use of Notepad in editing the script.

and don't ever write scripts using Windows, or you'll have to make use of tofrodos...

--ps: not in good moodmay be worse...

Thanks!

Of course, it is quite possible for me to be wrong in my guess about Kwrite editting, but please take for granted, I only did all my exercises under a stand alone Debian 5.04 "Lenny" system (no Windows, no virtual machine, no Wine at all). I did learn about some Notepad annoying on the net and I can not simply reject the hypothesis that very-very similar issues happen in my case (there are even 100% identical error messages in my case!). I'm quite responsible about what I speak about and I do intend to get an answer in that matter.

Thanks a lot, though I've only told the truth (in that I certainly did all my exercises under a Debian box) it is quite possible that your suspicion solve my problem. There is no joke here but just an amazing event in the past! I do promise to post here the final answer!

Well I did check at home and my hope was not confirmed: I simply do not have an explanation why the bash script does work under a shell session but fails to work under X. Possibly an explanation will arise unexpectedly in the future.

I'm not sure I understand how you are executing the script. Are you running './myscript.sh' from a terminal, or double clicking the icon for the script file (i.e. through nautilus)? If you're going through nautilus, it should prompt you for an option to run it in a terminal; otherwise, you can change the script to run 'gnome-terminal --execute /usr/bin/mc'.

Now, after several attempts and re-editting of the script, I get no message at all, but simply no effect. Rather curious is the ^M charracter combination above (in the error message) which I never typed in my scripts.

2. My attempts merely consist in double mouse clicking directly on the script icon which is located on the user Desktop (therefore, no nautilus or Dolphin etc etc but only straightforward double click on the icon). Any way, I'm working under KDE though having installed both GNOME and KDE as well.

3. By the way, some scripts do work correctly, if /usr/bin/mc is replaced by another binary. For instance, the following scripts does work under X sessions:

Code:

!#/bin/bashnautilusexit

However I was not able to notice clear criteria about which binary are accepted and which not. For instance, the ls command (instead of /usr/bin/mc) doesn't work (i.e. it produces no effect when trying to execute). Any way, all scripts which I tested till now do work correctly when run under true shell sessions.

Well, the executables do run, it's just that there's nothing hooked up to watch them -- i.e., it's not an interactive shell session. In the case of midnight commander, I suspect it checks to make sure it's in an interactive session, and if it's not, it just dies (if it didn't die, you could run 'ps' and see it). With something like ls, it could care less whether or not it's in an interactive session (try changing your script to run 'touch somefile' instead and you'll see that the file is created). With graphical programs (nautilus, for example), their purpose is not to run in a shell, but to start a graphical application, so they don't generally care if they are started in an interactive session.

1. I think there is a good chance that your explanation be right. For instance, I tested the same procedure (i.e. double click on the script icon) under a GNOME session and everything went OK (the MC window did pop up as expected).2. Furthermore, things go identically for perl instead of bash scripts (i.e. failure under KDE and success under GNOME).3. So could you please help me a bit more about how to fine tuning KDE in order for the user to get interactive bash sessions for scripts (as it is the case for my GNOME environment).

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum