|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
I'm developing software for Linux on my desktop. The software gets compiled and the binary is downloaded to the target system where i can't install a debugging system or something. I've written following code: #ifdef INIT_REPORT std: fstream out("/usr/share/NovaxTSP/INITreport.txt", std::ios_base::in |std::ios_base: ut | std::ios_base::app);if(!out) { // if out couldn't be opened, print error and exit std::cout << "Cannot open reportfile: \"/usr/share/NovaxTSP/INITreport.txt\"." << std::endl; exit(0); } std::string str = newLine + "\n"; out << newLine.c_str() << std::endl; out.close(); #endif The problem is, it works just fine on my desktop but it returns with "/usr/share/NovaxTSP/INITreport.txt" on the target system. I'm root and i do have write access to /usr/share/NovaxTSP/. I have tried "touch /usr/share/NovaxTSP/INITreport.txt" but this didn't either. df -h shows that I'm not running out of space either Does any one have any other idea what could go wrong? Thanks, Ron |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Ron Eggler wrote:
> Hi, > > I'm developing software for Linux on my desktop. The software gets compiled > and the binary is downloaded to the target system where i can't install a > debugging system or something. > I've written following code: > #ifdef INIT_REPORT > std: fstream out("/usr/share/NovaxTSP/INITreport.txt", std::ios_base::in |> std::ios_base: ut | std::ios_base::app);Is this combination of flags legit? > if(!out) { // if out couldn't be opened, print error and exit > std::cout << "Cannot open reportfile: > \"/usr/share/NovaxTSP/INITreport.txt\"." << std::endl; Odds are good that errno is probably valid here, assuming you're using gcc. Try adding: #include <cerrno> #include <cstdio> at the top, and adding std::cout << std::strerror(errno) in your error message. > exit(0); > } > std::string str = newLine + "\n"; > out << newLine.c_str() << std::endl; > out.close(); > #endif > > The problem is, it works just fine on my desktop but it returns > with "/usr/share/NovaxTSP/INITreport.txt" on the target system. I'm root > and i do have write access to /usr/share/NovaxTSP/. I have > tried "touch /usr/share/NovaxTSP/INITreport.txt" but this didn't > either. > df -h shows that I'm not running out of space either > Does any one have any other idea what could go wrong? > > Thanks, > Ron > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Ron Eggler wrote:
> Hi, > > I'm developing software for Linux on my desktop. The software gets compiled > and the binary is downloaded to the target system where i can't install a > debugging system or something. > I've written following code: > #ifdef INIT_REPORT > std: fstream out("/usr/share/NovaxTSP/INITreport.txt", std::ios_base::in |> std::ios_base: ut | std::ios_base::app);> if(!out) { // if out couldn't be opened, print error and exit > std::cout << "Cannot open reportfile: > \"/usr/share/NovaxTSP/INITreport.txt\"." << std::endl; > exit(0); > } > std::string str = newLine + "\n"; > out << newLine.c_str() << std::endl; > out.close(); > #endif > > The problem is, it works just fine on my desktop but it returns > with "/usr/share/NovaxTSP/INITreport.txt" on the target system. I'm root > and i do have write access to /usr/share/NovaxTSP/. I have > tried "touch /usr/share/NovaxTSP/INITreport.txt" but this didn't > either. > df -h shows that I'm not running out of space either > Does any one have any other idea what could go wrong? > You may also get better answers in gnu.g++., or one of the many linux programming newsgroups. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Feb 25, 7:12 pm, Ron Eggler <noth...@example.com> wrote:
> Hi, > > I'm developing software for Linux on my desktop. The software gets compiled > and the binary is downloaded to the target system where i can't install a > debugging system or something. > I've written following code: > #ifdef INIT_REPORT > std: fstream out("/usr/share/NovaxTSP/INITreport.txt", std::ios_base::in |> std::ios_base: ut | std::ios_base::app);> if(!out) { // if out couldn't be opened, print error and exit > std::cout << "Cannot open reportfile: > \"/usr/share/NovaxTSP/INITreport.txt\"." << std::endl; > exit(0); > } > std::string str = newLine + "\n"; > out << newLine.c_str() << std::endl; > out.close(); > #endif > > The problem is, it works just fine on my desktop but it returns > with "/usr/share/NovaxTSP/INITreport.txt" on the target system. I'm root > and i do have write access to /usr/share/NovaxTSP/. I have > tried "touch /usr/share/NovaxTSP/INITreport.txt" but this didn't > either. > df -h shows that I'm not running out of space either > Does any one have any other idea what could go wrong? > > Thanks, > Ron On your previous posting of the same exact problem, people adviced to use tools such as 'touch' and 'strace' in order to diagonise your problem. It would have ed much if you had followed up on that and not started a new thread. At least people who try to would know where they stand. Regards. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
diligent.snail@gmail.com wrote:
> On Feb 25, 7:12 pm, Ron Eggler <noth...@example.com> wrote: >> Hi, >> >> I'm developing software for Linux on my desktop. The software gets >> compiled and the binary is downloaded to the target system where i can't >> install a debugging system or something. >> I've written following code: >> #ifdef INIT_REPORT >> std: fstream out("/usr/share/NovaxTSP/INITreport.txt",>> std::ios_base::in | >> std::ios_base: ut | std::ios_base::app);>> if(!out) { // if out couldn't be opened, print error and exit >> std::cout << "Cannot open reportfile: >> \"/usr/share/NovaxTSP/INITreport.txt\"." << std::endl; >> exit(0); >> } >> std::string str = newLine + "\n"; >> out << newLine.c_str() << std::endl; >> out.close(); >> #endif >> >> The problem is, it works just fine on my desktop but it returns >> with "/usr/share/NovaxTSP/INITreport.txt" on the target system. I'm root >> and i do have write access to /usr/share/NovaxTSP/. I have >> tried "touch /usr/share/NovaxTSP/INITreport.txt" but this didn't >> either. >> df -h shows that I'm not running out of space either >> Does any one have any other idea what could go wrong? >> >> Thanks, >> Ron > > On your previous posting of the same exact problem, people adviced to > use tools such as 'touch' and 'strace' in order to diagonise your > problem. It would have ed much if you had followed up on that and > not started a new thread. At least people who try to would know > where they stand. Right, I thought I'd start over again by better explaining my situation with the target system. I didn't mention this in the other thread. I realized that I had done it wrongly and started over again. I'll now follow-up with red floyd's suggestion and will see how far I get with that. I appreciate every kind of ! Ron |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
red floyd wrote:
[snip] > > Odds are good that errno is probably valid here, assuming you're using > gcc. Try adding: > > #include <cerrno> > #include <cstdio> > > at the top, and adding > > std::cout << std::strerror(errno) Hi Floyed, This ed me alot, i changed my cout line to: std::cout << "Cannot open reportfile: \"/usr/share/NovaxTSP/INITreport.txt\". Error #:" << std::strerror(errno) << " Out: " << static_cast<bool>(out) << std::endl; and this is what I got: "Cannot open reportfile: "/usr/share/NovaxTSP/INITreport.txt". Error #:Success Out: 0" So I guess the if should be if (out< 0) to do the expected thing, right? PS I tried to static cast out to int but it wouldn't compile and since it's an if i thought I'd cast it to bool instead. Thanks, Ron > > in your error message. > [snip] |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Ron Eggler wrote:
> red floyd wrote: > > [snip] > >> >> Odds are good that errno is probably valid here, assuming you're using >> gcc. Try adding: >> >> #include <cerrno> >> #include <cstdio> >> >> at the top, and adding >> >> std::cout << std::strerror(errno) > > Hi Floyed, > > This ed me alot, i changed my cout line to: > std::cout << "Cannot open reportfile: > \"/usr/share/NovaxTSP/INITreport.txt\". Error #:" << std::strerror(errno) > << " Out: " << static_cast<bool>(out) << std::endl; > and this is what I got: > "Cannot open reportfile: "/usr/share/NovaxTSP/INITreport.txt". Error > #:Success Out: 0" > So I guess the if should be if (out< 0) to do the expected thing, right? > PS I tried to static cast out to int but it wouldn't compile and since > it's an if i thought I'd cast it to bool instead. No, not that simnple, I changed the if clause, ran it on the target and what I get nothing doing a /var/run/sbin # cat /usr/share/NovaxTSP/INITreport.txt /var/run/sbin # even tho it for sure would have written data in the file. Any other ? I'm pretty onfused here.... Thanks, Ron > >> >> in your error message. >> > [snip] |
|
![]() |
| Outils de la discussion | |
|
|