Strange behavior with tar

I am trying to create an archive using tar. I am specifying a list of directories using the -L option. For testing purposes I created a simple directory structure:

/backup/test
/backup/test/test1
/backup/test/test2

The file specified by the -L option, named files.txt, contains:
-C/backup/test
test1
test2

The command I am executing is:

 tar -cvf test.tar -Lfiles.txt

The archive is created, but I am getting some strange output. Here a sample:

tar: can't change directories to _=/usr/bin: No such file or directory
tar: can't change directories to TMPDIR=: No such file or directory
tar: LANG=en_US: No such file or directory
tar: can't change directories to tmp=: No such file or directory
.
.
.
a test1
a test2

There are "No such file or directory" messages for every environment variable currently set.

I have used this same method on Linux with no issues, but AIX is not cooperating.

Does anyone have any idea what could be causing this?

Thanks!!

What is - Cfiles.txt supposed to do?
for me -C is to change directory...

Linux is not UNIX hehe
(G)tar is not tar nor vim is vi...

oops, that is supposed to be -Lfiles.txt
the actual command that is producing the error strange behavior is:
tar -cvf test.tar -Lfiles.txt

...was up late trying to get this resolved

Whats is in that file? Because it seems the content isnt good (syntax or non printable chars?)
What the file generated from windows?

The file has only these 3 lines:
-C/backup/test
test1
test2

It was created on the server with vi. I don't see any control characters in it.

What is test1 test2 ?
/backup/test if is a directory it will create the directory, but will not backup the files in it...
the idea of -L is to give a list file with all you want for tar (and I suppose it does not use joker because I dont use it... haha
I will go and test...)

demo:

file.txt:
/usr/bin/
/usr/bin/ls
/usr/bin/vi
/usr/local/etc/
/usr/local/etc/*

n12:/home/vbe $ tar -cvf /home/vbe/test.tar -L/home/vbe/file.txt    
a /usr/bin/
a /usr/bin/ls 53 blocks
a /usr/bin/vi 713 blocks
a /usr/local/etc/
tar: /usr/local/etc/*: No such file or directory

So the listfile must be exaustif - no * ? ... only files and directories one by one...
and listing a directory doesnt mean it will backup its content...

On my RedHat Linux, "man tar" says:

I have never seen that -L flag behave the way you describe on Linux. -L is documented on IBM's AIX web site but it says it is a list of files and directories. "-C/backup/test" therefore should indicate that that the current directory has a subdirectory named "-C". You seem to think that you can put command line options in your file. I don't see any language to support that. But I have no AIX to test.

/backup/test is a directory, /backup/test/test1 and /backup/test/test2 are directories as well.

The command I am using to test this will not grab any files in test1 or test2, but if I add the -R option, it will.

Right now, I'm just trying to keep it simple to resolve this issue.

The purpose of doing this is that I want to archive test1 and test2, but I do not want the path to be stored.

So, given these directories:
/backup/test/test1
/backup/test/test2

I want to archive to contain test1 and test2, not /backup/test/test1 and /backup/test/test2.

files.txt could ultimately contain 100+ different directories to archive, which is why I am trying to use the -L option instead on using -C on the command line

---------- Post updated at 11:31 AM ---------- Previous update was at 11:29 AM ----------

the tar command is different between Linux and UNIX. On Linux, using a file to list the items to be archived it done with the "-T" option, but its done with "-L" on UNIX, at least AIX...