如何使R获取XP cmd命令的输出


> system("wmic cpu")    
AddressWidth  Architecture  Availability  Caption                           ConfigManagerErrorCode  ConfigManagerUserConfig  CpuStatus  CreationClassName  CurrentClockSpeed  CurrentVoltage  DataWidth  Description                       DeviceID  ErrorCleared  ErrorDescription  ExtClock  Family  InstallDate  L2CacheSize  L2CacheSpeed  LastErrorCode  Level  LoadPercentage  Manufacturer  MaxClockSpeed  Name                     OtherFamilyDescription  PNPDeviceID  PowerManagementCapabilities  PowerManagementSupported  ProcessorId       ProcessorType  Revision  Role  SocketDesignation  Status  StatusInfo  Stepping  SystemCreationClassName  SystemName       UniqueId  UpgradeMethod  Version         VoltageCaps      
32            0             3             x86 Family 6 Model 22 Stepping 1                                                   1          Win32_Processor    1862               13              32         x86 Family 6 Model 22 Stepping 1  CPU0                                      133       13                   1024         931                          6      8               GenuineIntel  1862           Intel Pentium II 处理器                                                                    FALSE                     AFEBFBFF00010661  3              5633      CPU   Socket 478         OK      3           1         Win32_ComputerSystem     LIGONG-A691B08A            13             型号 6,步进 1                   
> system("wmic cpu")->x    
AddressWidth  Architecture  Availability  Caption                           ConfigManagerErrorCode  ConfigManagerUserConfig  CpuStatus  CreationClassName  CurrentClockSpeed  CurrentVoltage  DataWidth  Description                       DeviceID  ErrorCleared  ErrorDescription  ExtClock  Family  InstallDate  L2CacheSize  L2CacheSpeed  LastErrorCode  Level  LoadPercentage  Manufacturer  MaxClockSpeed  Name                     OtherFamilyDescription  PNPDeviceID  PowerManagementCapabilities  PowerManagementSupported  ProcessorId       ProcessorType  Revision  Role  SocketDesignation  Status  StatusInfo  Stepping  SystemCreationClassName  SystemName       UniqueId  UpgradeMethod  Version         VoltageCaps      
32            0             3             x86 Family 6 Model 22 Stepping 1                                                   1          Win32_Processor    1862               13              32         x86 Family 6 Model 22 Stepping 1  CPU0                                      133       13                   1024         931                          6      4               GenuineIntel  1862           Intel Pentium II 处理器                                                                    FALSE                     AFEBFBFF00010661  3              5633      CPU   Socket 478         OK      3           1         Win32_ComputerSystem     LIGONG-A691B08A            13             型号 6,步进 1                   
> x    
[1] 0    

如何使 X 获取 wmic cpu 的输出字符串?

使用intern=T参数。有关详细信息,请查看 R 控制台中的?system

x <- system("wmic cpu", intern = T)
x
## [1] "AddressWidth  Architecture  Availability  Caption                               ConfigManagerErrorCode  ConfigManagerUserConfig  CpuStatus  CreationClassName  CurrentClockSpeed  CurrentVoltage  DataWidth  Description                           DeviceID  ErrorCleared  ErrorDescription  ExtClock  Family  InstallDate  L2CacheSize  L2CacheSpeed  L3CacheSize  L3CacheSpeed  LastErrorCode  Level  LoadPercentage  Manufacturer  MaxClockSpeed  Name                                     NumberOfCores  NumberOfLogicalProcessors  OtherFamilyDescription  PNPDeviceID  PowerManagementCapabilities  PowerManagementSupported  ProcessorId       ProcessorType  Revision  Role  SocketDesignation  Status  StatusInfo  Stepping  SystemCreationClassName  SystemName      UniqueId  UpgradeMethod  Version  VoltageCaps  r"
## [2] "64            9             3             Intel64 Family 6 Model 42 Stepping 7                                                   1          Win32_Processor    2697               15              64         Intel64 Family 6 Model 42 Stepping 7  CPU0                                      100       6                    1024                       6144         0                            6      3               GenuineIntel  3101           Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz  4              4                                                                                            FALSE                     BFEBFBFF000206A7  3              10759     CPU   CPU 1              OK      3                     Win32_ComputerSystem     CHINMAY-OFFICE            1                                    r"
## [3] "r

最新更新