Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > 1C.Linux system commands

Forum

Search UsersRules
1C.Linux system commands
#1
Active user
Points:: 0
Joined:: Aug 28, 2015

Hello.
How can i execute a system command on Linux from 1C? The task is to execute the following command:
udevadm info --query=all --name=/dev/sda | grep ID_SERIAL_SHORT
and to get hard drive serial number from 1C. I will be grateful for any help!

Profile
#2
Administrator
Points:: 0
Joined:: Oct 3, 2019

Hello Samir,

you can try to do something like this:


Code
System("udevadm info --query=all --name=/dev/sda | grep ID_SERIAL_SHORT >> temp.txt");
textReader = New TextReader;
textReader.Open("/home/username/temp.txt");
line = textReader.ReadLine();
While line <> Undefined Do 
   
EndDo;


That is, first we give the command to write the serial number of the disk to the file, and then we read the data from this file.

Profile
#3
Just came
Points:: 0
Joined:: Jan 17, 2023

Hello this is Gulshan Negi
Well, to execute a system command on Linux from 1C, you can use the built-in mechanism for running external programs - ShellExecute.
Example:-
CommandText = "udevadm info --query=all --name=/dev/sda | grep ID_SERIAL_SHORT";
ShellExecute(CommandText, "", "", ExecutionMode::Asynchronous);
This code will execute the udevadm info command with the provided parameters and pipe its output to grep ID_SERIAL_SHORT to extract the serial number. The output of the command will be captured by 1C and can be processed further.
I hope it will help.
Thanks

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.