hello
I trying to run a program called bb with this Linux shell code and its looking in this directories:
trying to run bb in /usr/lib/lightdm/lightdm
trying to run bb in /usr/local/sbin
trying to run bb in /usr/local/bin
trying to run bb in /usr/sbin
trying to run bb in /usr/bin
trying to run bb in /sbin
trying to run bb in /bin
trying to run bb in /usr/games
trying to run bb in /usr/local/games
and there is no results
any ideas?
why its not looking in all directories of the system?
Holon Institute of Technology/ B.Sc Computer Science / Operation Systems Course with Dr.Wiseman
Unless you are required to implement the path lookup yourself, there are exec* functions which will check the components of PATH until a matching file is found. Those variants have a 'p' in their name, such as execvp, execlp, etc.
Unrelatedly, what if there are more than 19 components in PATH? Your code cannot cope with that situation. (Although this would be unacceptable for production code, it may be acceptable for the purpose of this homework assignment.)
If you do find and run the executable, should you abort the search? Your code will attempt to run multiple commands with the same name, if they exist.
The initial argument for these functions is the pathname of a file which is to be executed.
The file is the executable's file name prefixed with an entire path. You supply a path, but no executable.
BTW, wouldn't it be better to fork once and then try to execute a file than forking and failing exec n times, each time wasting a resource consuming process creation?
but I do use execv in the right syntax:
syntax:int execv(const char *path, char *const argv[]);
my: execv(paths[pathindex],arg);
The type of each argument that you pass to execv may be correct, but paths[pathindex] is a path to a directory where execv expects a path to an executable.
For additional feedback, if execv returns -1, you can check the value of errno.
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
2. Relevant commands, code, scripts, algorithms:
Write a command to display lines ending with the... (1 Reply)
plz i need code to search about numbers like this :
962785785698
962795565488
962785321565
962777321684
962795979515
i need code to detect just numbers start with "96278"
i need it in awk !!
thanks (1 Reply)
A shell script is a script written for the shell, or command line interpreter, of an operating system. Typical operations performed by shell scripts include file manipulation, program execution, printing text etc.
Shell : In computing, a shell is a piece of software that provides an interface for... (1 Reply)
1. Write a shell script to print the file names of all files having .txt extension of a given directory after converting to uppercase letters. The input (directory name) should be given as command line argument. The script will also check whether sufficient arguments are passed or not and whether... (1 Reply)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Hi, since I'm relatively new to Unix I need some help. I've installed FreeBSD 8 on a virtual machine and I've done... (4 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Hello,
My name is Jordan and studying at the New Bulgarian University in Sofiya. This is my homework but can... (2 Replies)
Discussion started by: freestar
2 Replies
7. Post Here to Contact Site Administrators and Moderators