[Gambas-user] Help with redirecting stdout of the GNU shred command (SHELL/EXEC)
vikram
austinium at ...43...
Wed May 26 07:05:47 CEST 2010
Hi,
I am new to
Gambas and this is my first application. I have been working with
C/VC++ and Gambas has been fun so far except for this little problem
i've run into...
I am trying to make a GUI front end for the
GNU shred command. I have got to the stage where the user can select a
file via GUI and shred(using SHELL). I am trying to make it more
interactive by reading stdout from shred -v into the Gambas
application. I have followed
http://www.gambasforum.com/index.php?topic=120.0;wap2 and tried to use
EXEC to read stdout, haven't had much luck with it so far :(
Heres the code:
'global variables
PRIVATE filename AS String
PRIVATE delfile AS Boolean
PRIVATE shredprocess AS Process
PRIVATE shredcommanddel AS String[3]
PRIVATE shredcommandnodel AS String[3]
'this is where i initialize the command arrays for EXEC
'the last element is replaced later by the filepath
PUBLIC SUB Form_Open()
'tbx_filename
shredcommanddel = ["shred ", "-uv ", " "]
shredcommandnodel = ["shred ", "-v ", " "]
END
'Display a file open dialog and save the path of the file selected to filepath
PUBLIC SUB btn_fileselect_Click()
IF Dialog.OpenFile() THEN RETURN
filename = Dialog.Path
tbx_filename.Text = filename
END
'the actual shredding happens here, the code with EXEC is ineffective at the moment it doesnt shred the file
'SHELL works, but i dont know how to redirect stdout with either of these
PUBLIC SUB btn_shred_Click()
'DIM shellcommand AS String[]
'Message(filename)
IF delfile THEN
'shellcommand = "shred --remove --verbose " & filename
shredcommanddel[2] = filename
shredprocess = EXEC shredcommanddel 'FOR READ
SHELL "shred -uv " & filename
ELSE
'shellcommand = "shred --verbose " & filename
shredcommandnodel[2] = filename
shredprocess = EXEC shredcommandnodel 'FOR READ
SHELL "shred -v " & filename
ENDIF
'SHELL shellcommand FOR READ AS "Process"
END
'Execution never gets here
PUBLIC SUB Process_Read()
DIM resultline AS String
LINE INPUT #shredprocess, resultline
Message("HERE WE ARE!")
resultline = resultline & GB.NewLine
END
PUBLIC SUB CheckBox1_Click()
delfile = TRUE
END
I am looking for a way to redirect output from the shred to my Gambas application.
Appreciate your help in this.
Thanks,
Vikram
More information about the User
mailing list