My C++ program cannot access any file by function - GetStat() and open() on ubuntu arm & amd 22 instance on AWS

0

Hi, my C++ program cannot access any file on Ubuntu arm and amd 22 instance on AWS, but it can work well on my local machines. All of files permission denied when the program tried to access these files by the function - open and gestat which are coming from c++ standard lib.

asked 3 months ago149 views
1 Answer
0

There are a few things you can check to troubleshoot the issue of your C++ program not being able to access files on your ARM/AMD instances on AWS running Ubuntu:

  • File Permissions: Ensure that the files you're trying to access have the appropriate permissions set. On the AWS instance, you may need to grant your program's user account (or the user running the program) the necessary read/write permissions to access the files (specifically ownership of the files in question). You can do this using the chmod command.

  • File Paths: Double-check that the file paths you're using in your program are correct and match the actual locations of the files on the AWS instance. Relative paths may not work as expected, so try using absolute paths to ensure the program can locate the files.

  • Compatibility: Verify that the C++ standard library functions you're using (open and gestat) are supported and functioning as expected on the Ubuntu ARM and AMD instances offered by AWS. There might be some compatibility issues or differences in the library implementations between your local machines and the AWS instances.

To further investigate the issue, you could try the following:

  • Add more error handling and logging in your C++ program to capture the specific error messages or codes when the file access fails on the AWS instances.
  • Run your program on the AWS instance with elevated privileges (e.g., using sudo) to see if that resolves the permissions issue.
  • Try accessing the files using alternative methods, such as the POSIX system calls (open, stat) or file stream classes (fstream) to see if the problem is specific to the standard library functions you're using.
  • Check the AWS instance's logs and system-level logs (under /var/log/) for any relevant error messages or clues about the file access issues.

By investigating these different aspects, you should be able to identify the root cause of the problem and find a solution to get your C++ program working correctly on the Ubuntu ARM and AMD instances.

AWS
SUPPORT ENGINEER
answered 3 months ago
  • I used a command to display the file, I found it indeed existed, but the system shows it not found. ubuntu@ip-172-31-8-158:~$ sudo -u ubuntu ./STAR/STAR.fmdevtest.com.crt ./STAR/STAR.fmdevtest.com.crt: 1: -----BEGIN: not found ./STAR/STAR.fmdevtest.com.crt: 2: MIIGNjCCBR6gAwIBAgIRAOstJljHnTTUynILlfojWK8wDQYJKoZIhvcNAQELBQAw: not found ./STAR/STAR.fmdevtest.com.crt: 3: gY8xCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO: not found ./STAR/STAR.fmdevtest.com.crt: 4: BgNVBAcTB1NhbGZvcmQxGDAWBgNVBAoTD1NlY3RpZ28gTGltaXRlZDE3MDUGA1UE: not found ./STAR/STAR.fmdevtest.com.crt: 5: AxMuU2VjdGlnbyBSU0EgRG9tYWluIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZlciBD: not found ./STAR/STAR.fmdevtest.com.crt: 6: QTAeFw0yNDA1MDEwMDAwMDBaFw0yNTA1MjYyMzU5NTlaMBoxGDAWBgNVBAMMDyou: not found ./STAR/STAR.fmdevtest.com.crt: 7: Zm1kZXZ0ZXN0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANJk: not found ./STAR/STAR.fmdevtest.com.crt: 8: rQ6lB0xvfPQAoqa2ErYIkglpbJPK+2X0sWs4gBh10Czn3D23HSJAG8r9RWuV9Nnq: not found ./STAR/STAR.fmdevtest.com.crt: 9: h1OreKVoRKhSIqxB620SstL181uIVX4T0SwUZOIUKG8gCFQJFwJjXwkSbAN+yvjc: not found ./STAR/STAR.fmdevtest.com.crt: 10: FgANV9Pv0tD9rCIVi2pQX4DNOsHS/DZy99Cr2wUsdUyGnr3FRZkyaa57BwwD5Ez0: not found ./STAR/STAR.fmdevtest.com.crt: 11: f+qFKY9zjLYBICOSIp7Qyv0+Xz/ktO3r7Qjj0fCpoB3gsGOy4omuV8v1oTN9OtxQ: not found ./STAR/STAR.fmdevtest.com.crt: 12: mWtwSAH48LpVuDADSxjiZr7ztGrPkK6ULmQBuFOxW8I2z2Z1EUQM7TUD1mOduTz0: not found It only shows part of them, is this a compatibility issue?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions