473,513 Members | 2,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regarding fopen and chmod

3 New Member
#include<stdio.h>
#include<unistd.h>

Hi,

when i execute the following code both lakshmi and sri gets printed,later
if i give pwd in the path /home/tcsbasr/CFILES the following statement is
displayed.

"pwd: cannot determine current directory!"

if i give ls the below statement is displayed.

".: Permission denied"

Please let me know why the above statements are getting printed.

Expand|Select|Wrap|Line Numbers
  1. void main()
  2. {
  3.  
  4.         char d1[256];
  5.     char d[30]="/home/tcsbasr/CFILES/";
  6.     FILE *fp1;
  7.  
  8.     if(chmod(d,777)==0)
  9.     printf("lakshmi");
  10.  
  11.     fp1=fopen("/home/tcsbasr/CFILES/y.c","w");
  12.     if(fp1==NULL)
  13.     printf("sri");
  14.  
  15. }    

Thanks,
lakshmi
May 18 '07 #1
1 14004
AdrianH
1,251 Recognized Expert Top Contributor
777 is not what you want. You want 0777. Having a leading 0 make the
number be interpreted as an octal number.


Adrian
May 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
7138
by: bird | last post by:
What can cause the PHP code fopen("filename","a") to fail with permission denied message as below? ------------------ Warning: fopen(filename): failed to open stream: Permission denied in...
9
2785
by: monomaniac21 | last post by:
Hi everyone i'm trying to setup my website to create new webpages dynamically using php but I am have a major problem in that whenever i create a file it is always created locked so that it can...
2
6181
by: Joseph S. | last post by:
Hi all, Consider this case: I have a free php hosting account (a LAMP host) with an account name (also the name of my directory) 'sample'. Under 'sample', I have php scripts which can create...
0
1763
by: foekall | last post by:
I used this script and test on my hosting. Evertimes appear "change permission to 777 failed. ". So, how to solve this error. Please kindly check for me and teach me. <?php $MAX_SIZE =...
8
3563
by: FFMG | last post by:
Hi, My users can upload images in a folder on my system. What minimum attribute should I give the created, (@fopen($new_file, 'wb');), files and folder? I limit the extension of files,...
16
4655
by: Hans Fredrik Nordhaug | last post by:
I'm trying to write to a file in the current directory - no remote files. The subject says it all - I can add that both the directory and the file is wordwritable. This happens on a (quite good)...
3
3440
by: IamtheEvster | last post by:
Hi there, I'm using fopen for the first time and I know I'm running into a permissions problem, but I can't seem to resolve it and any help would be greatly appreciated. I'm running PHP5 and...
8
9592
by: Alien | last post by:
Hi, I have a question regarding the fopen( ) function. I wrote this piece of code: #include <stdio.h> int main() { FILE *fp;
20
5077
by: cscorley | last post by:
For some reason, I cannot use fopen() on the file in write mode. The file "time" is in the same directory as the .php file, with permissions set to 0766. PHP Version 5.2.5 Apache/2.2.8 code...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.