Linux Help

Linux specific forum
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Linux Help

Post by TronDoc »

It would be nice if any Linux Gurus pass through
and post a tip or two here..
..I'm not a Guru, but I've found a couple of things
with trying to use PureBASIC under Linux.

you have to manually set permissions before
you can execute a binary you've created.
(any Guru with a script that will compile, chmod, etc?)

you can "run" code directly by: pbcompiler filename.pb

you can "run" your compiled binary using: ./filename.bin

Joe
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
Iria
User
User
Posts: 43
Joined: Sat Nov 29, 2003 8:49 pm

Well bizzarely you could just write your own little....

Post by Iria »

Why not code a simple PB console app for linux that does what you want...

Just shell out the commands to CHMOD 766 xxxx.exe, rename the executable to a linux std, i.e. no extension. Even move it to a debug/test directory. Shouldnt be that hard?

Regards

Andy
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Re: Well bizzarely you could just write your own little....

Post by TronDoc »

Iria wrote:Why not code a simple PB console app for linux that does what you want...
duh :oops: never thought of that.
thanks for the chmod value.. ..that I didn't know what to set as.
Joe
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
Iria
User
User
Posts: 43
Joined: Sat Nov 29, 2003 8:49 pm

this may help you....

Post by Iria »

Chmod is a little more involved but for simple high level permission setting I found this little site...

http://javascriptkit.com/script/script2/chmodcal.shtml

which simply lets you work out in a nice human readable form what permission values to use to get different results.

hope that helps ...
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

thanks for the chmod calculator link!
I can't get runprogram to do it though...

Code: Select all

;RunProgram(FileName$ [, Parameter$, WorkingDirectory$ [, Flags]])
FileName$ = "chmod" : Parameter$ = "744 testfile" : WorkingDirectory$ = ""
RunProgram(FileName$ , Parameter$, WorkingDirectory$)

;RunProgram("chmod","744 testfile","") :;chmod complains "too few arguments"
;RunProgram("chmod"," 744 testfile","") :;chmod complains "too few arguments"
;RunProgram("chmod","744","./testfile") :;chmod complains "too few arguments"
;RunProgram("chmod","744 testfile","") :;chmod complains "too few arguments"
;RunProgram("chmod","744 testfile","./") :;chmod complains "too few arguments"
;RunProgram("chmod","-c 744 testfile","") :;chmod complains "invalid option"
;RunProgram("chmod","-c744 testfile","") :;chmod complains "too few arguments"
;RunProgram("chmod","--help","")  :;this works!
End
:roll:
--jb
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Just a thought, try RunProgram("chmod 744 ./testfile", "", "") maybe varying the path. I would try it myself but I debugging on a dual boot box.
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

that gives no error, but doesn't change the permissions either.
I'm trying variations without success.
--jb
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

As root or restricted user? What is the pb programs permissions? Have you checked the log (tail /var/log/messages), not sure if/where an attempt to chmod without permissions would be reported. Keep the info coming though, I have solve my problem and can boot up Linux if it helps.
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

O.K.
root can't do it either, but that doesn't seem to be the problem.
it seems to be the passing of parameters in general, not just to chmod.
I've also discovered something weird about the Linux I am using:
from the terminal window the permissions show
a binary created by PureBASIC as executable, and it IS!
BUT using the Nautilus "Graphic Shell" (file browser) the same
file's permissions show NOT executable.
It's as if the O.S. is keeping two separate permissions lists.
One for the terminal mode and one for the GUI mode.!?

None of that explains why I can't properly pass parameters.
Can anyone give an example of code successfully passing
parameters from one Linux executable to another?

Joe
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

First, I would trust the terminal over Nautilus.

The best I can get is chmod actual running by supplying "/bin/chmod" (seperately) but it reports "too few arguments". I have tried a variety of paths but it would appear PB not passing the argument. Also tried as root but same result. Fred?
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

@TronDoc: solved?
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

nope. :(
I got distracted and wrote a chmodCALCulator :oops:
I hope to morph that into a chmodGUI, but still can't
get the progargs to process like they should :roll:
Joe
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

anybody figured this out yet?
Joe
BlindMan
User
User
Posts: 32
Joined: Thu Aug 30, 2018 11:34 am

Re: Linux Help RunProgram("chmod", "777 /tmp/test.sh", ""

Post by BlindMan »

Works as expected using PB 572 x64 on Ubuntu 18.04 x64

Code: Select all


  If CreateFile(0, "/tmp/test.sh")
    WriteStringN(0, "#!/bin/bash")
    WriteStringN(0, "ls -lA > /tmp/test.txt")
    CloseFile(0)
  Else
    MessageRequester("Error", "Unable to create script")
  EndIf

  RunProgram("chmod", "777 /tmp/test.sh", "")
  Delay(1000)
  RunProgram("/tmp/test.sh")
  
  End

Post Reply