1. system("sudo ...
- Posted by JerryStory Sep 26, 2008
- 1170 views
Gotta problem with system() on GNU/Linux. It seems to not handle sudo well.
constant WXEU = "libwxeu.so.12" -- -- system("sudo cp " & WXEU & " /usr/local/lib",0) system("sudo ldconfig /usr/local/lib",0)
It has to either to ask for a password or not need a password. It's not asking for a password and it's not copying the file. What do I gotta do?
2. Re: system("sudo ...
- Posted by bernie Sep 26, 2008
- 1165 views
Gotta problem with system() on GNU/Linux. It seems to not handle sudo well.
constant WXEU = "libwxeu.so.12" -- -- system("sudo cp " & WXEU & " /usr/local/lib",0) system("sudo ldconfig /usr/local/lib",0)
It has to either to ask for a password or not need a password. It's not asking for a password and it's not copying the file. What do I gotta do?
Hi Jerry;
Maybe system_exec() would work did you try that ?
3. Re: system("sudo ...
- Posted by JerryStory Sep 26, 2008
- 1154 views
- Last edited Sep 27, 2008
Gotta problem with system() on GNU/Linux. It seems to not handle sudo well.
constant WXEU = "libwxeu.so.12" -- -- system("sudo cp " & WXEU & " /usr/local/lib",0) system("sudo ldconfig /usr/local/lib",0)
It has to either to ask for a password or not need a password. It's not asking for a password and it's not copying the file. What do I gotta do?
Hi Jerry;
Maybe system_exec() would work did you try that ?
system_exec() doesn't handle sudo. And system() doesn't handle sudo.
What we need is something that pauses, creating a console if needed, and asks for a password.
4. Re: system("sudo ...
- Posted by SDPringle Sep 27, 2008
- 1186 views
system and system_exec probably do work inspite of your observations.
You see, Linux run from the GUI will not create a console when you need one. It is not supposed to. The program sudo is just writing to standard output and waiting on standard input. Try prepending xterm -e to the strings passed into system.
Shawn Pringle
5. Re: system("sudo ...
- Posted by JerryStory Sep 27, 2008
- 1104 views
system and system_exec probably do work inspite of your observations.
You see, Linux run from the GUI will not create a console when you need one. It is not supposed to. The program sudo is just writing to standard output and waiting on standard input. Try prepending xterm -e to the strings passed into system.
Shawn Pringle
Do you mean like this?
system("xterm -e sudo cp " & WXEU & " /usr/local/lib",1) system("xterm -e sudo ldconfig /usr/local/lib",1)
That didn't work. Didn't ask for a password and didn't copy into /usr/local/lib I'm using the terminal provided by editor Kate.
6. Re: system("sudo ...
- Posted by ChrisB (moderator) Sep 27, 2008
- 1154 views
Hi
Works on mine (SuSE 10.0) - get terminal screen, asks for passwords, and copies a file.
I replaced WXUE with a filename in the string, so is WXEU correct?
Chris
7. Re: system("sudo ...
- Posted by JerryStory Sep 27, 2008
- 1154 views
Hi
Works on mine (SuSE 10.0) - get terminal screen, asks for passwords, and copies a file.
I replaced WXUE with a filename in the string, so is WXEU correct?
Chris
Replacing WXEU with "libwxeu.so.12" didn't make any difference. I'm using Ubuntu, if that matters. But it needs to work on all distros.
8. Re: system("sudo ...
- Posted by ChrisB (moderator) Sep 27, 2008
- 1134 views
Hi
Doen't Ubuntu have a strange method of handling the root user? Have you tried just copying a file to a directory to which you have permission first to see if there's an issue there.
I imagine you're trying to set up an installation script. It may be simpler just to use a bash script, just to get the job done.
Chris
9. Re: system("sudo ...
- Posted by mattlewis (admin) Sep 27, 2008
- 1151 views
Gotta problem with system() on GNU/Linux. It seems to not handle sudo well.
constant WXEU = "libwxeu.so.12" -- -- system("sudo cp " & WXEU & " /usr/local/lib",0) system("sudo ldconfig /usr/local/lib",0)
It has to either to ask for a password or not need a password. It's not asking for a password and it's not copying the file. What do I gotta do?
Are you running from a terminal? The following gives me prompts (and correct output) when appropriate:
system("whoami", -2 ) ? system_exec( "whoami", -2 ) system("sudo whoami", -2 ) ? system_exec( "sudo whoami", -2 )
matt matt 0 [sudo] password for matt: root root 0
But I think the bigger question is why are you doing this? We're all trying to solve this problem for you, but it's the sort of problem that is often better solved by trying something different. Why does you're program want to copy stuff here? It looks like an install script. Can you just have the user run the program run with root permissions (i.e., have them run the script as sudo to begin with)? Maybe a few more details would help to solve the problem.
Matt
10. Re: system("sudo ...
- Posted by JerryStory Sep 27, 2008
- 1178 views
But I think the bigger question is why are you doing this? We're all trying to solve this problem for you, but it's the sort of problem that is often better solved by trying something different. Why does you're program want to copy stuff here? It looks like an install script. Can you just have the user run the program run with root permissions (i.e., have them run the script as sudo to begin with)? Maybe a few more details would help to solve the problem.
Matt
The history of this project is something like this.
1. People had difficulty installing dmak (which is based on wxEuphoria). This requires dmak itself, the .so portion of wxEuphoria, and the USDA data. And I had difficulty explaining it to them. And sometimes it has to be the right version of wxEuphoria.
2. The ideal solution would be a .deb file or somesuch kind of file. That would be the professional way. But I don't know how to do that.
3. Then I learned about wget. I thought "Hey! This might have possibilities!" So first I tried to make an installer program in bash. That ran into a problem that I don't remember. Next I used Euphoria instead of bash.
4. But it refuses to copy libwxeu.so.12 into /usr/local/lib
Here is the installer, source and binaries. http://www3.telus.net/%7Ejtstory/programs-dmak/install_wxprogs.zip
Maybe someone can fix it.
11. Re: system("sudo ...
- Posted by jimcbrown (admin) Sep 27, 2008
- 1173 views
4. But it refuses to copy libwxeu.so.12 into /usr/local/lib
Here is the installer, source and binaries. http://www3.telus.net/%7Ejtstory/programs-dmak/install_wxprogs.zip
Maybe someone can fix it.
I just tried it (adding "su root -c " to before the "cp" command, which lacked the "sudo ", and replacing "sudo " with "su root -c " for "ldconfig" command) and it works fine. Asks for the password twice and then it says its installed. Tested with Ubuntu Breezy.
12. Re: system("sudo ...
- Posted by JerryStory Sep 27, 2008
- 1143 views
4. But it refuses to copy libwxeu.so.12 into /usr/local/lib
Here is the installer, source and binaries. http://www3.telus.net/%7Ejtstory/programs-dmak/install_wxprogs.zip
Maybe someone can fix it.
I just tried it (adding "su root -c " to before the "cp" command, which lacked the "sudo ", and replacing "sudo " with "su root -c " for "ldconfig" command) and it works fine. Asks for the password twice and then it says its installed. Tested with Ubuntu Breezy.
Do you mean like this?
system("su root -c cp " & WXEU & " /usr/local/lib",1) system("su root -c ldconfig /usr/local/lib",1)
I tried that and it didn't ask for a password and nothing happened in /usr/local/lib. To test this program, you need to rename or delete libwxeu.so.12 in /usr/local.lib and see if it puts libwxeu.so.12 in /usr/local/lib.
13. Re: system("sudo ...
- Posted by jimcbrown (admin) Sep 27, 2008
- 1102 views
Do you mean like this?
system("su root -c cp " & WXEU & " /usr/local/lib",1) system("su root -c ldconfig /usr/local/lib",1)
I tried that and it didn't ask for a password and nothing happened in /usr/local/lib. To test this program, you need to rename or delete libwxeu.so.12 in /usr/local.lib and see if it puts libwxeu.so.12 in /usr/local/lib.
Yes, I did, yes I was prompted for the password (twice), and yes it was copied there. I ran "exu install_wxprogs.exw" inside of an xterm, though.
14. Re: system("sudo ...
- Posted by SDPringle Sep 27, 2008
- 1041 views
Do you mean like this?
system("su root -c cp " & WXEU & " /usr/local/lib",1) system("su root -c ldconfig /usr/local/lib",1)
I tried that and it didn't ask for a password and nothing happened in /usr/local/lib. To test this program, you need to rename or delete libwxeu.so.12 in /usr/local.lib and see if it puts libwxeu.so.12 in /usr/local/lib.
Yes, I did, yes I was prompted for the password (twice), and yes it was copied there. I ran "exu install_wxprogs.exw" inside of an xterm, though.
Perhaps you should use sudo but make sure you are in the sudoers file and provide the full path instead of just the name of sudo. Test the command in a shell. sudo might be in /sbin or /usr/sbin.
Shawn Pringle
15. Re: system("sudo ...
- Posted by mattlewis (admin) Sep 27, 2008
- 1129 views
I tried that and it didn't ask for a password and nothing happened in /usr/local/lib. To test this program, you need to rename or delete libwxeu.so.12 in /usr/local.lib and see if it puts libwxeu.so.12 in /usr/local/lib.
The easy solution is to require the user to run your program using sudo or as root so that the permissions are taken care of before you ever get to these calls.
Matt