1C.Linux system commands

The 1C:Enterprise developers forum

People who like this:0Yes/0No
Active user
Rating: 2
Joined: Aug 28, 2015

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!

People who like this:0Yes/0No
Rating: 23
Joined: Oct 3, 2019

Hello Samir,

you can try to do something like this:

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

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.

People who like this:0Yes/0No
Just came
Rating: 1
Joined: Jan 17, 2023
Company: Techatom Pvt Ltd

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.
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.

Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.