在Windows系统上,我正在尝试收集DNS名称的所有IP地址,并使用每个IP地址调用工具。我知道如何从Shell脚本执行操作-但不知道如何从批处理或Powershell文件执行操作。
我想将此移植到Windows。
import { PermissionsAndroid } from 'react-native';
async function getLocation() {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
'title': 'App',
'message': 'are you sure you want to share your location with the app ?'
}
)
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
// permission granted
// do code get location here.
navigator.geolocation.getCurrentPosition(
(pos) => {
console.log(pos.coords.longitude, pos.coords.latitude);
})
} else {
// permission denied
console.log("GPS permission denied")
}
} catch (err) {
console.warn(err)
}
}
问题:
#!/usr/bin/env bash
# Get all the IPs for our server instance
# and pass it to "p4 trust" to update the .p4trust file
for address in $(dig perforce.example.com +short)
do
echo "processing address: $address:1666"
p4 -p "ssl:$address:1666" trust -y -f || true
done
仅返回DNS记录的IP?答案 0 :(得分:2)
尝试一下...
Get-Command -Name Resolve-Dns* | Format-Table -AutoSize
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Resolve-DnsName 1.0.0.0 DnsClient
# Get parameters, examples, full and Online help for a cmdlet or function
(Get-Command -Name Resolve-DnsName).Parameters
Get-help -Name Resolve-DnsName -Examples
Get-help -Name Resolve-DnsName -Full
Get-help -Name Resolve-DnsName -Online
# Get all IPAddresses for the provided DNS name
$env:USERDNSDOMAIN | ForEach{Resolve-DnsName -Name $_}
Name Type TTL Section IPAddress
---- ---- --- ------- ---------
CONTOSO.COM A 600 Answer 192.168....
CONTOSO.COM A 600 Answer 10.10...
#
$env:USERDNSDOMAIN |
ForEach{
# Get all IPAddresses for the provided DNS name
$DNSIPA = (Resolve-DnsName -Name $_).IPAddress
# Check if the host is up for a given IPA and port number
ForEach($IPA in $DNSIPA)
{
"Processing $IPA"
Test-NetConnection -ComputerName $IPA -Port 1666
}
}
但是,此问题将转化为您是PowerShell的新手。因此,在导致不必要的混乱/挫败感等之前,至关重要的是,您必须花时间使用所有可用的免费PowerShell视频和电子书培训资源来加快速度。这里只是几个。