Quote:
Originally Posted by davidgeek
I am a newbie to command scripting
|
What you are writing is not a command script, but a C program.
Quote:
Code:
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
system("cd ./home/alice/Public; ./mysecret ';ls -l /home/alice/Private;'");
}
|
This won't work, since there is no program named "cd".
You can however use the chdir() system call prior to calling system():
Code:
if ( chdir("/home/alice/Public")<0 )
perror("Couldn't cd to /home/alice/Public");
The problem is that Charlie is unlikely to have the right permissions to cd to Alice's home directory.
Also, I don't know what "mysecret" is supposed to accomplish and I find the parameter to "mysecret" very strange - why does it start with a semicolon?
Quote:
Q2. Write a script/program to display the application password and the secret of the admin user.
Solution: This question I really do not even know how to start
|
Neither do I, as I am utterly lacking context; what are the application and the secret mentioned in the question?