add command text output to textarea.
Posted
#1
(In Topic #1355)
Regular

Basically i'm trying to run a shell command and feed the output back to a textarea.
I figured out how to get Gambas to confirm a command with the user password. Here's what I've got so far:
Dim Command As String
Command = "pkexec ls /root"
Shell Command Wait For Read As "Answer"
It's a step further than what i had, which was when i hit the Command Button i got no prompt
Apologies again for all the questions but i do have to say that gambas is HIGHLY addictive.
Posted
Regular

Posted
Guru

Posted
Regular

Posted
Regular

Dim sResult As String
Shell "ls -a" To sResult
TextArea1.Text = sResult
I don't mean to double post but in case someone in the future is having trouble with the same issue then let it be noted as "SOLVED"
Posted
Regular

i tried running :
Dim sResult As String
Dim command As String
command = ("lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL") To sResult
TextArea1.Text = sResult
but I keep getting an unexpected 2 error. I have no idea on how to handle errors. Can you help me out again!!!
Posted
Regular

unexpected to fmain class 12
Posted
Guru

Where's the Shell command gone?
/lang/shell - Gambas Documentation
your shell command cannot run itself in gambas code you need to use Shell or Exec
Posted
Regular

Posted
Regular

Posted
Regular

Dim sResult As String
Dim command As String
command = "sudo fdisk -l"
Shell command To sResult
TextArea1.Text = sResult
Posted
Regular

Posted
Guru

Try pkexec,
pkexec will open the GUI password requester and allow your root command to pass
you MUST run a pkexec command with XAUTHORITY and DISPLAY environment variables like this for 'lsblk -l'..
Or this..
Or this..
1 guest and 0 members have just viewed this.


