1. system("sudo ...

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?

new topic     » topic index » view message » categorize

2. Re: system("sudo ...

JerryStory said...

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 ?

new topic     » goto parent     » topic index » view message » categorize

3. Re: system("sudo ...

bernie said...
JerryStory said...

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.

new topic     » goto parent     » topic index » view message » categorize

4. Re: system("sudo ...

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: system("sudo ...

SDPringle said...

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.

new topic     » goto parent     » topic index » view message » categorize

6. Re: system("sudo ...

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

new topic     » goto parent     » topic index » view message » categorize

7. Re: system("sudo ...

ChrisB said...

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.

new topic     » goto parent     » topic index » view message » categorize

8. Re: system("sudo ...

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

new topic     » goto parent     » topic index » view message » categorize

9. Re: system("sudo ...

JerryStory said...

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 ) 
console said...

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

new topic     » goto parent     » topic index » view message » categorize

10. Re: system("sudo ...

mattlewis said...

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.

new topic     » goto parent     » topic index » view message » categorize

11. Re: system("sudo ...

JerryStory said...

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.

new topic     » goto parent     » topic index » view message » categorize

12. Re: system("sudo ...

jimcbrown said...
JerryStory said...

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.

new topic     » goto parent     » topic index » view message » categorize

13. Re: system("sudo ...

JerryStory said...

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.

new topic     » goto parent     » topic index » view message » categorize

14. Re: system("sudo ...

jimcbrown said...
JerryStory said...

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

new topic     » goto parent     » topic index » view message » categorize

15. Re: system("sudo ...

JerryStory said...

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu