XARGS limitations?

Don't miss a thing. Post your questions and discussion about other uncategorized NAS features here.

XARGS limitations?

Postby cegrell » Thu Jul 12, 2012 4:16 am

Hi
I'm trying to do a basic batch file copy/rename using xargs, but it's not working. Any ideas (or other tips how to accomplish the same thing)?

Code: Select all
find //path/ -name \*.jpg | xargs -i{} cp {} {}.backup


What I'm trying to do is to find all *.jpg files in any subdirectory in /path and make a copy to the same directory but with the added .backup suffix.

Not sure if the QNAP xargs version is limited or if I'm just typing it wrong (have tried -I, -n1 too), but it's not working. Any other ideas how to accomplish this would be most welcome. Thanks.

I'm on a TS-109 Pro Version 3.3.0 build 0924T.
TS-109 PRO Version 3.3.0 build 0924T
cegrell
Starting out
 
Posts: 40
Joined: Thu Feb 21, 2008 5:38 pm
Location: Lund
NAS Model: TS-109/209

Re: XARGS limitations?

Postby tmt » Thu Jul 12, 2012 11:36 am

The builtin xargs is just busybox, and it's totally crippled. Install optware and use that one.

Code: Select all
[~] # /usr/bin/xargs --help
BusyBox v1.01 (2012.06.14-17:24+0000) multi-call binary

Usage: xargs [COMMAND] [OPTIONS] [ARGS...]

Executes COMMAND on every item given by standard input.

Options:
        -r      Do not run command for empty readed lines
        -x      Exit if the size is exceeded
        -0      Input filenames are terminated by a null character
        -t      Print the command line on stderr before executing it.

[~] #
SS-439, Ubuntu Server 12.04.2 LTS, EXT4, RAID10, 4xHitachi 5K1000
TS-112, 3.7.3 20120801, EXT4, 1xHitachi 7K1000
tmt
Been there, done that
 
Posts: 977
Joined: Mon Nov 16, 2009 11:02 am
NAS Model: SS-439 Pro

Re: XARGS limitations?

Postby pwilson » Thu Jul 12, 2012 12:31 pm

cegrell wrote:I'm trying to do a basic batch file copy/rename using xargs, but it's not working. Any ideas (or other tips how to accomplish the same thing)?

Code: Select all
find //path/ -name \*.jpg | xargs -i{} cp {} {}.backup


What I'm trying to do is to find all *.jpg files in any subdirectory in /path and make a copy to the same directory but with the added .backup suffix.

Not sure if the QNAP xargs version is limited or if I'm just typing it wrong (have tried -I, -n1 too), but it's not working. Any other ideas how to accomplish this would be most welcome. Thanks.



tmt wrote:The builtin xargs is just busybox, and it's totally crippled. Install optware and use that one.

Code: Select all
[~] # /usr/bin/xargs --help
BusyBox v1.01 (2012.06.14-17:24+0000) multi-call binary

Usage: xargs [COMMAND] [OPTIONS] [ARGS...]

Executes COMMAND on every item given by standard input.

Options:
        -r      Do not run command for empty readed lines
        -x      Exit if the size is exceeded
        -0      Input filenames are terminated by a null character
        -t      Print the command line on stderr before executing it.

[~] #


There is no "xargs" ipkg per se. To get "xargs" simply install the "findutils" IPKG

Code: Select all
admin@NASTY2:/root# ipkg install findutils                                                                                                   
Installing findutils (4.2.32-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable/findutils_4.2.32-1_arm.ipk
Configuring findutils
update-alternatives: Linking //opt/bin/find to /opt/bin/findutils-find
update-alternatives: Linking //opt/bin/xargs to /opt/bin/findutils-xargs
Successfully terminated.


Oh yeah, after installing the Optware "findutils" IPKG:

Code: Select all
admin@NASTY2:/root# xargs --help
Usage: xargs [-0prtx] [--interactive] [--null] [-d|--delimiter=delim]
       [-E eof-str] [-e[eof-str]]  [--eof[=eof-str]]
       [-L max-lines] [-l[max-lines]] [--max-lines[=max-lines]]
       [-I replace-str] [-i[replace-str]] [--replace[=replace-str]]
       [-n max-args] [--max-args=max-args]
       [-s max-chars] [--max-chars=max-chars]
       [-P max-procs]  [--max-procs=max-procs] [--show-limits]
       [--verbose] [--exit] [--no-run-if-empty] [--arg-file=file]
       [--version] [--help] [command [initial-arguments]]

Report bugs to <bug-findutils@gnu.org>.


This should give you your "-i" switch in "xargs" to play with.... :D

Hope this helps....

Patrick

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-419P+ w/ 4 * Seagate Barracuda 2TB 5900rpm (RAID5) - FW: 3.8.1 Build 20121205
Forums: View My Profile - Search My Posts - Send Private Message - View My Photo - Top Community Forum Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs - HowTos - QNAP Video Library
User avatar
pwilson
Moderator
 
Posts: 3819
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada
NAS Model: TS-419P+

Re: XARGS limitations?

Postby cegrell » Fri Jul 13, 2012 2:57 am

pwilson wrote:There is no "xargs" ipkg per se. To get "xargs" simply install the "findutils" IPKG


Brilliant! Just what I was after. Worked like a charm. Thanks!!
TS-109 PRO Version 3.3.0 build 0924T
cegrell
Starting out
 
Posts: 40
Joined: Thu Feb 21, 2008 5:38 pm
Location: Lund
NAS Model: TS-109/209

Re: XARGS limitations?

Postby schumaku » Fri Jul 13, 2012 3:46 am

Just a note: In general, it might be nice to get "stanards" compliant commands in place. However, this can inerfer with an kind of QNAP Firmware supplied scripts and Web CGI program - as thier code is drawn to the utilities as availbakle by default....
User avatar
schumaku
Guru
 
Posts: 22317
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
NAS Model: TS-x79 Pro

Re: XARGS limitations?

Postby pwilson » Fri Jul 13, 2012 9:58 am

schumaku wrote:Just a note: In general, it might be nice to get "stanards" compliant commands in place. However, this can inerfer with an kind of QNAP Firmware supplied scripts and Web CGI program - as thier code is drawn to the utilities as availbakle by default....


The reality of your observation is quite bothersome.

There is no excuse for this! As NAS units typically have lots of storage available, I'm still trying to understand why "BusyBox" is being used in the first place. BusyBox makes sense on devices like Routers that have limited Flash space as their only storage, but on a NAS it is a terrible thing to install.

I note that IMPORTANT Notes! section of the QNAP Wiki article: Running Your Own Application at Startup Note#2 provides the advice: "Always use the full system path because locations like /opt/bin or /opt/sbin might not have been exported yet when the Autorun.sh is executed"

If QNAP's scripts insist on using the limited "BusyBox" apps (symlinks to Busybox), they should be calling the them as "busybox <command>" rather than "<command>", OR they should be defining the PATH variable at the beginning of their scripts, to ensure the correct command is run OR they should be using the full system path when calling commands.

I guess I'll have to check whether I'm in a "interactive" session, before I redefine the PATH variable in my .profile/.bashrc files. In your "opinion" (ie I won't hold you to it), do you think this will be sufficient to allow "non-interactive" sessions like QNAP scripts to function properly. (I thank you for sharing this unpopular reality, at least now I know to look for this when I discover issues).

In most cases the Optware commands will be a superset of the busybox ones, however I know this is not always true.

This is horrifying. Totally horrifying. There is simply no excuse for using "Busybox" in the first place.

Patrick.

Patrick.
This is irresponsible programming. I am being constantly biten by the limitations of busybox, and am constantly using Optware replacements to solve these problems.

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-419P+ w/ 4 * Seagate Barracuda 2TB 5900rpm (RAID5) - FW: 3.8.1 Build 20121205
Forums: View My Profile - Search My Posts - Send Private Message - View My Photo - Top Community Forum Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs - HowTos - QNAP Video Library
User avatar
pwilson
Moderator
 
Posts: 3819
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada
NAS Model: TS-419P+

Re: XARGS limitations?

Postby schumaku » Fri Jul 13, 2012 5:03 pm

Modern BusyBox does have almost no such limitation. Bet it's simply cumbersome for QNAP to port everyting from legacy BuysBox commands and parameters to the new real world. The majority of code is made long before the NAS became "open" :shock:

Undoubted, only _one_ version of each command should exist on a system in my opinion - the need to replace de-facto standard tools and utilities should not exist at all.

Afraid, exaclty the critical ones are not supersets - BusyBox was vey limied and different at that time, and had a different scope, too.

Of course, you ae perfectly corrrect - but _any_ change would require changing code, testing, re-testing, ...
User avatar
schumaku
Guru
 
Posts: 22317
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
NAS Model: TS-x79 Pro


Return to Miscellaneous

Who is online

Users browsing this forum: No registered users and 2 guests