Command Output Redirection
Posted: Monday 9th March 2020 2:35pm
I have an application in which I import Linux system information by piping the output of a Linux command to a file, then reading the contents of the file into my application e.g
dim strCommand as String
dim strUSBDevices as string
dim myFile as File
strCommand = "lsusb > usb_devices.txt"
shell strCommand
myFile = open "usb_devices.txt" for input
line input #myFile, strUSBDevices
myFile.close
Obviously, you would expect the command to return more than one USB device, so the file would have multiple lines, but you get the point.
My question is this: Is there a way to redirect the output of the Linux command to write directly to a string variable declared in the application, thereby removing the need for the file?
Thanks
Beeza
dim strCommand as String
dim strUSBDevices as string
dim myFile as File
strCommand = "lsusb > usb_devices.txt"
shell strCommand
myFile = open "usb_devices.txt" for input
line input #myFile, strUSBDevices
myFile.close
Obviously, you would expect the command to return more than one USB device, so the file would have multiple lines, but you get the point.
My question is this: Is there a way to redirect the output of the Linux command to write directly to a string variable declared in the application, thereby removing the need for the file?
Thanks
Beeza