I am not able to do a dns lookup in prepare.sh ?
I have tried this : server_ip=$(nslookup pc.pc | grep -A 1 ‘Name:.'“pc.pc” | grep -o 'Address.1:.[0-9.]’ | awk ‘{print $3}’)
Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!
Did you like my answer?
Hello,
When attempting to perform a DNS lookup using nslookup within a prepare.sh script on a Verdin iMX8M Plus with TorizonCore, there are a few considerations to ensure the command executes correctly. Your command seems to be attempting to parse the output of nslookup to extract an IP address, but there might be syntax issues or environmental constraints affecting its execution.
Syntax Check: Ensure your command syntax is correct, especially the use of quotation marks and backticks. The command as provided seems to have formatting issues, particularly with the quotation marks. Ensure you’re using standard single (') or double (") quotes in the shell script.
Network Configuration: Verify that the DNS service is correctly configured and accessible in your Torizon environment. If your container or the TorizonCore system does not have a proper DNS setup, nslookup will fail to resolve the hostname.
Command Availability: Ensure that nslookup is available in your environment. nslookup might not be installed by default in the minimal TorizonCore containers. You may need to install it manually using your container’s package manager (e.g., apt-get install dnsutils for Debian-based containers).
Alternative Approach: Consider using a different tool like dig or getent hosts if nslookup continues to give you trouble. These tools can also perform DNS lookups and might be more straightforward to use in scripts.
Debugging: Add error handling in your script to catch and understand any issues. For instance, directly run nslookup pc.pc to ensure it outputs the expected result before parsing it.
Permissions: Ensure your script has the necessary permissions to execute and that it’s running in an environment with network access.
If after these checks, you’re still facing issues, it might be helpful to directly test the nslookup command outside of the script to ensure the DNS resolution works as expected in your Torizon environment. Also, reviewing the network configuration on your Verdin iMX8M Plus and ensuring that the DNS servers are reachable from your device is crucial.
Best regards,
Toradex AI Assistant
Please, also check if these links can help you solve your problem:
Thank you for contacting us and welcome to our community.
May I ask you what you would like to use it for? What is the grand goal behind it? We would like to know this, to ensure that it is really necessary, since prepare.sh is it is a part of “Toradex easy installer”.
It is possible, that there is an issue within your network.
Could you try nslookup pc.pc as well as cat /etc/resolve.conf after booting the Toradex easy installer and send us the outputs? Also have you tried this on another machine?