Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a file 1

Status
Not open for further replies.

fergmj

Programmer
Feb 21, 2001
276
US
I want to create a file on my webserver and set the chmod to 666. However, I seem to have to create the file manually. I know how to rmdir to remove directories and such but how do I make actual *.txt files from Perl code and set the permissions?

Thanks

 
$file = "file.txt";
open(F, ">$file") or die "Can't open $file: $!\n";
print F "hello world\n";
close(F);
chmod 0666, $file;
 
raider2001

Actually the above does not create the txt file on my server. It has to already exist before it doesn't error.

$filedatename = "$currentdate$counter\.txt";
$tstone = "GB$filedatename";
open (TS, ">>$tstone") || dienice("Can't open Thunderstone TextFile");
flock(TS,2);
seek(TS,0,2);
$fs = chr(28);
$a100 = "1:00 4";
print TS "$fs$a100";
close(TS);
chmod 0666, $tstone;


Any other thoughts?

fergmj
 
I just ran my code on a Linux system and it works for me. Your code also works fine. Are you sure this isn't a permissions problem on the directory?
 
What should I chmod the folder to?

What is your set for??
 
WORKS WHEN I SET IT TO 777


THANK YOU!!!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top