美文网首页
终端拿到关于本机里的信息

终端拿到关于本机里的信息

作者: 皮蛋豆腐酱油 | 来源:发表于2019-10-21 14:47 被阅读0次
    system_profiler SPHardwareDataType
    
    system_profiler 的其他类型通过system_profiler -listDataTypes可知
    
    Available Datatypes:
    SPParallelATADataType
    SPUniversalAccessDataType
    SPSecureElementDataType
    SPApplicationsDataType
    SPAudioDataType
    SPBluetoothDataType
    SPCameraDataType
    SPCardReaderDataType
    SPComponentDataType
    SPiBridgeDataType
    SPDeveloperToolsDataType
    SPDiagnosticsDataType
    SPDisabledSoftwareDataType
    SPDiscBurningDataType
    SPEthernetDataType
    SPExtensionsDataType
    SPFibreChannelDataType
    SPFireWireDataType
    SPFirewallDataType
    SPFontsDataType
    SPFrameworksDataType
    SPDisplaysDataType  //图形卡/显示器
    SPHardwareDataType
    SPHardwareRAIDDataType
    SPInstallHistoryDataType
    SPLegacySoftwareDataType
    SPNetworkLocationDataType
    SPLogsDataType
    SPManagedClientDataType
    SPMemoryDataType  //内存
    SPNVMeDataType
    SPNetworkDataType
    SPPCIDataType
    SPParallelSCSIDataType
    SPPowerDataType
    SPPrefPaneDataType
    SPPrintersSoftwareDataType
    SPPrintersDataType
    SPConfigurationProfileDataType
    SPRawCameraDataType
    SPSASDataType
    SPSerialATADataType
    SPSPIDataType
    SPSmartCardsDataType
    SPSoftwareDataType
    SPStartupItemDataType
    SPStorageDataType
    SPSyncServicesDataType
    SPThunderboltDataType
    SPUSBDataType
    SPNetworkVolumeDataType
    SPWWANDataType
    SPAirPortDataType
    

    参考:https://blog.csdn.net/LIHUINIHAO/article/details/54772722

    - (NSString *)getProduceDate {
        NSString *modelIdentifier = @"";
        NSString *cmd1 = @"system_profiler SPHardwareDataType | grep 'Model Identifier'";
        modelIdentifier = [IProcessMgr cmdShellScript:cmd1];
        modelIdentifier = [modelIdentifier substringFromIndex:24];
        modelIdentifier = [modelIdentifier stringByReplacingOccurrencesOfString:@"\n" withString:@""];
        
        NSString *date = @"";
        NSString *path = @"/System/Library/PrivateFrameworks/ServerInformation.framework/Versions/A/Resources/English.lproj/SIMachineAttributes.plist";
        NSDictionary *SIMachineAttributesDic = [[NSDictionary alloc] initWithContentsOfFile:path];
        for (NSString *s in SIMachineAttributesDic.allKeys) {
            if ([s isEqualToString:modelIdentifier]) {
                NSDictionary *infoDic = [[SIMachineAttributesDic objectForKey:s] objectForKey:@"_LOCALIZABLE_"];
                date = [infoDic objectForKey:@"description"];
                break;
            }
        }
        NSLog(@"date = %@",date);
        
        
        
        return date;
    }
    

    相关文章

      网友评论

          本文标题:终端拿到关于本机里的信息

          本文链接:https://www.haomeiwen.com/subject/aoetvctx.html