LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-14-2007, 01:03 PM   #1
c_h_i_ll_a_x
LQ Newbie
 
Registered: Jun 2007
Location: India
Posts: 4

Rep: Reputation: 0
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

Last edited by c_h_i_ll_a_x; 06-14-2007 at 01:04 PM.
 
Old 06-14-2007, 01:18 PM   #2
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
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.
 
Old 06-14-2007, 01:58 PM   #3
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Or do it in a for loop:
Code:
for i in *.rpm; do rpm -i -v --ignoresize $i; done
That way your argument list is only ever using a single file, but it will still do the whole directory-full.

Note: this is untested, so I might be wrong !
 
Old 06-14-2007, 03:22 PM   #4
dawkcid
Member
 
Registered: May 2007
Location: UK
Distribution: LFS,Slackware,Slamd64,NetBSD
Posts: 102

Rep: Reputation: 15
Quote:
Can anyone tell me what is the maximum length of a command?
getconf ARG_MAX

(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.

Last edited by dawkcid; 06-14-2007 at 03:25 PM.
 
Old 06-15-2007, 08:22 AM   #5
c_h_i_ll_a_x
LQ Newbie
 
Registered: Jun 2007
Location: India
Posts: 4

Original Poster
Rep: Reputation: 0
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
 
Old 06-17-2007, 12:24 PM   #6
dawkcid
Member
 
Registered: May 2007
Location: UK
Distribution: LFS,Slackware,Slamd64,NetBSD
Posts: 102

Rep: Reputation: 15
No, rpm doesn't rollback, each package is effectively processed individually.
 
Old 06-18-2007, 03:33 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,258

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
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.
 
Old 07-04-2007, 10:15 AM   #8
c_h_i_ll_a_x
LQ Newbie
 
Registered: Jun 2007
Location: India
Posts: 4

Original Poster
Rep: Reputation: 0
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...
 
Old 07-04-2007, 02:25 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by c_h_i_ll_a_x
Hi all,
Thanks for the suggestions but I have one more doubt.
No, you don't. You have a question.
There's a reason this place is called Linuxquestions,
not Linuxdoubts.




Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Name length Slamtilt Linux - Newbie 2 03-22-2006 06:16 PM
mp3 length command bendeco13 Linux - General 2 03-21-2005 02:02 AM
Command line tool to print length of mp3 files? J_Szucs Linux - Software 3 05-04-2004 06:01 AM
Command to list line length of multiple scripts Tekime Linux - General 2 09-06-2002 02:04 AM
message length boku LQ Suggestions & Feedback 2 08-05-2002 12:57 PM


All times are GMT -5. The time now is 11:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration