What is the maximum length of a command?
Hi all,
I am using the following command in my script. But I am not sure if this will break because of the maximum length of command that is allowed in LINUX. The command I am using is: rpm -i -v --ignoresize *.rpm The directory contains more than 2000 rpms. So I guess this will create a long command after evaluation of *.rpm and may break. Can anyone tell me what is the maximum length of a command? Thx, c_h_i_ll_a_x |
I get "broken" commands all the time, nothing will happen, bash will spit out "argument list to long". 2000 arguments dosent sound to bad, about on the border i think. If it does break, all you have to do is break up the command, using "find" together with "xargs" is a good method.
|
Or do it in a for loop:
Code:
for i in *.rpm; do rpm -i -v --ignoresize $i; done Note: this is untested, so I might be wrong ! ;) |
Quote:
(typically 128K on Linux) BTW, a for loop will work fine, but execs a new instance of the command for each file. As SciYro mentioned, find | xargs is a more efficient solution. |
Hi all,
Thanks for the suggestions but I have one more doubt. In case of "rpm *.rpm" command if one of the rpms fails to install, does the rpm utility rollback/uninstall all the rpms that are already installed before the failed one (such that if not all rpms are installed then there shouldn't be any). If this is the case then we don't have to do clean-up. But if I use find and xargs then I have to do clean-up my self for already installed rpms. For example in the below command, rpm will process each rpm separately. find . -name '*.rpm' | xargs rpm -i -v --ignoresize - c_h_i_ll_a_x |
No, rpm doesn't rollback, each package is effectively processed individually.
|
Why don't you use the pkg mgr that comes with your distro, then you won't even have to think about it?
Pls add your distro to your info. |
Hi all,
Now I am working on a different approach. I want to create a new binary that would take a directory as an argument. Internally, this program would collect the list of files and build an RPM transaction and then tell RPM to process the transaction. But I am not sure how to do this. I have looked into some info on net but couldn't find the right. Has anyone looked into programming with RPM or how to use rpm.h interface? Please help... |
|
All times are GMT -5. The time now is 12:28 PM. |