General discussion

Locked

Message 'Argument too long'

By dodik ·
I loged in as user:
user: tif , group: other

I have to copy 5000 files from one folder to another folder:

cp ./folder1/* ./folder2/

but I receive message: "Argument too long"

in terminal console I switched user: "su"
user: root, group: other

cp ./folder1/* ./folder2/ now it works !
But I need to process this as user: tif.
What I heve to do?

Also why "exec ./myscript" command works but "sopurce ./myscript" does NOT ?
(I use c shell)

Thanks.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by Black Panther In reply to Message 'Argument too lon ...

Copying Files and Folders in Unix may have problems depending on the File permissions.

If another user owns the files ie root for example and user tif trys to copy them - they may have trouble unless the permissions are changed.

You can actually copy the files as the super user 'root' and then change the file permissions
ie owner, group, and other same as windows
to be owned by user tif using the unix commands
chown and also chmod

for more info type # man chown
# man chmod

otherwise you would have to open up the file permission for the user tif to be able to copy them
the exec problem may be permission related as well

Collapse -

by dodik In reply to

Nothing to do with my problem.
Anyway thanks.

Collapse -

by Gary_W In reply to Message 'Argument too lon ...

Before the shell executes your command line, it replaces the splat (*) with a list of all the files (full pathname) in the current directory. One of them causes cp to fail, most likely due to restrictions on your non-root user account. Try a method that does not require wildcard expansion, like:
cp -r folder1 folder2
Keep in mind that with *NIX there are often many ways to accomplish the same thing, some more appropriate than others, depending on what you are trying to do.

For your second question, do a 'man' on exec to see the manual page (man exec). 'exec' executes "./myscript" in place of the current shell, which terminates.
"source" reads commands from name. source commands may be
nested, but if they are nested too deeply the shell may run
out of file descriptors. An error in a sourced file at any
level terminates all nested source commands.

exec executes, source reads from. note the waring in the "source" description about nested commands. Perhaps this is what you ran into.

Gary

Collapse -

by dodik In reply to

Thanks again, Gary

Collapse -

by dodik In reply to Message 'Argument too lon ...

This question was closed by the author

Back to Linux Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums