473,767 Members | 2,166 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 14066
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
7157
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 /home/lookout/u2/kmei/www/test1.php on line 14 ------------------ I write a short PHP code that works fine on my own apache server, but it doesn't work after I upload it to the university server. Note that 'chmod 777 filename' works as expected.
9
2799
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 only be read even when i specify read and write access. Here is a basic example of the code I am using (I am using a Mac OSX 10.3.9):
2
6196
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 files and folders programmatically. I have manually created a directory called 'users' under 'sample' and have given it a chmod 777 successfully. >From my script in 'sample', say myscript.php, I can successfully create any number of files inside...
0
1781
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 = 2000000;
8
3573
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, (images), but I want to prevent them from executing any code on the server. What attributes would you suggest?
16
4696
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) free hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the PHP info below shows ... Test it at: http://home.no.net/moldevbk/fopen-test/?mode=w (write - fails) http://home.no.net/moldevbk/fopen-test/?mode=a (append - ok)...
3
3452
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 Apache on RedHat Enterprise Linux 4. I've verified (by looking in httpd.conf) that Apache is running as user "apache" and group "apache". So, that's the user/group that PHP
8
9629
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
5114
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 snip in question: $file = "time";
0
9404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10009
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9838
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8835
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5279
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3929
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.