[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]


    Search the Q&A Archives


From the UNIX (HP-UX 11.11) command prompt (if I do not have...

<< Back to: Unix Programming FAQ (v1.37)

Question by Jaunine
Submitted on 1/19/2004
Related FAQ: Unix Programming FAQ (v1.37)
Rating: Not yet rated Rate this question: Vote
From the UNIX (HP-UX 11.11) command prompt (if I do not have a file no.txt), I type the following command:

mv no.txt yes.txt

Here is the result:

mv: no.txt: cannot access: No such file or directory

Here is the problem:
I run this command via a C program, using popen(), using the following lines of code (this is only a snippet of my C code):

int stat;
fptr = popen(cmdbuf, "r");
strcpy(cmdbuf,"mv no.txt yes.txt");
stat = pclose(fptr);
printf("Value for WEXITSTATUS: %d\n", WEXITSTATUS(stat));
printf("Value for errno: %d: %s\n", stat);
printf("Error description: ... %s ...\n", strerror(stat));

The result when I run this program:
Value for WEXITSTATUS: 1
Value for errno: 256
Error description: ...  ...

Can anybody please tell me how I can retrieve the correct error description? It should thus say the following:

Value for WEXITSTATUS: 1
Value for errno: 256
Error description: ... mv: no.txt: cannot access: No such file or directory ...

Help would be MUCH appreciated.
Thanks!



Your answer will be published for anyone to see and rate.  Your answer will not be displayed immediately.  If you'd like to get expert points and benefit from positive ratings, please create a new account or login into an existing account below.


Your name or nickname:
If you'd like to create a new account or access your existing account, put in your password here:
Your answer:

FAQS.ORG reserves the right to edit your answer as to improve its clarity.  By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions. You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damages resulting from publishing your answer.

 

FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personal opinion of the poster. These posts are not intended to substitute for medical, tax, legal, investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinion or any product or service mentioned mentioned in these posts.

 

<< Back to: Unix Programming FAQ (v1.37)


[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]

© 2008 FAQS.ORG. All rights reserved.