473,386 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Checking if a file exist

Hey All,
I'm a bit new at this,and i tryed seraching google about it but i
didn't quite got a solution.
I'm writing an HTML page that needs to check if another html file exist
(in the same folder) and if not,to call to a C file and create that
html file.
I tryed to do that with JavaScript but i understood there is no such
option.
Can u advice?
and once i know that file doesn't exist,can i call to a C file from a
simple html page?

Thanks a lot!

Oct 25 '05 #1
23 11395
wrote on 25 okt 2005 in comp.lang.javascript:
Hey All,
Not my name,
I'm a bit new at this,and i tryed seraching google about it but i
didn't quite got a solution.
I'm writing an HTML page that needs to check if another html file exist
(in the same folder) and if not,to call to a C file and create that
html file.
I tryed to do that with JavaScript but i understood there is no such
option. Can u advice?
This is not sms, please use only usenet abbreviations.
and once i know that file doesn't exist,can i call to a C file from a
simple html page? Thanks a lot!


[We didn't do anything yet, so why the thanks.]

If you are talking javascript in a browser on a page from a server on
internet, the js has no security clearance for files on the client.

Javascript on a local .hta file or in wscript is a different matter.

The same goes for serverside javascrpt [on an ASP platform]

Which of the 4 is your Q about?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 25 '05 #2
ba****@gmail.com wrote:
I'm writing an HTML page that needs to check if another html file exist
HTML is a data format, it can't "do" anything.
(in the same folder) and if not,to call to a C file and create that
html file.
Call to a C file? Do you mean "execute a binary created by compiling
source C source code"?
I tryed to do that with JavaScript but i understood there is no such
option.
Client side JavaScript runs with very low permissions. Its almost
certainly the wrong tool for what you are doing.
Can u advice?


It sounds like you need to set up your webserver so that when a file is
requested, it checks to see if it exists, and if it doesn't, create the
file and then returns the result.

Apache is the industry standard webserver and certainly has this
capability. I'd get a copy of the Eagle book if I were you, it goes
over how to do this sort of thing. (It should be a fairly simple
content handler).

http://www.oreilly.com/catalog/wrapmod/

Oct 25 '05 #3
You could use the ActiveX scripting object, but I don't recomend it!

do a search on:

ActiveXObject("Scripting.FileSystemObject")

IE only though...

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.242...
wrote on 25 okt 2005 in comp.lang.javascript:
Hey All,


Not my name,
I'm a bit new at this,and i tryed seraching google about it but i
didn't quite got a solution.
I'm writing an HTML page that needs to check if another html file exist
(in the same folder) and if not,to call to a C file and create that
html file.
I tryed to do that with JavaScript but i understood there is no such
option.

Can u advice?


This is not sms, please use only usenet abbreviations.
and once i know that file doesn't exist,can i call to a C file from a
simple html page?

Thanks a lot!


[We didn't do anything yet, so why the thanks.]

If you are talking javascript in a browser on a page from a server on
internet, the js has no security clearance for files on the client.

Javascript on a local .hta file or in wscript is a different matter.

The same goes for serverside javascrpt [on an ASP platform]

Which of the 4 is your Q about?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 25 '05 #4
Thanks for the quick response.
by calling to a C file , i did mean to execute a compiled source code.
i'm writing a program that generates these html pages,do i still need
to look at the Apache? I meen,i'm not creating a website or anything
like that...

Oct 25 '05 #5
wrote on 25 okt 2005 in comp.lang.javascript:

[please always quote on usenet, this is not email]
Thanks for the quick response.
by calling to a C file , i did mean to execute a compiled source code.
i'm writing a program that generates these html pages,do i still need
to look at the Apache? I meen,i'm not creating a website or anything
like that...


Compiled sourcecode is not sourcecode anymore. You mean executable?

Please first answer my Q on what platform.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 25 '05 #6
All local. JavaScript on a local html page

Oct 25 '05 #7
Sorry for the english. I ment an executable C file.

Oct 25 '05 #8
wrote on 25 okt 2005 in comp.lang.javascript:
All local. JavaScript on a local html page


Sorry,
if you persist in using usenet as email by not quoting where you are
replying on, so that others cannot follow the read,
I will not anwer you anymore.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 25 '05 #9
This is my firt time here. i wasn't sure on how to reply.

Oct 25 '05 #10
wrote on 25 okt 2005 in comp.lang.javascript:
This is my firt time here. i wasn't sure on how to reply.


you are not learning!

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 25 '05 #11
I'm sorry! so please explain how to reply...it's my first time...
i just pressed on the link that says "response" ,so tell me,
what do i need to do to reply correctly?

Oct 25 '05 #12
wrote on 25 okt 2005 in comp.lang.javascript:
I'm sorry! so please explain how to reply...it's my first time...
i just pressed on the link that says "response" ,so tell me,
what do i need to do to reply correctly?


It all depends on what news-reader you use
[xnews. agent, outlook]
or perhaps a web-news form, like Google groups.

You can easily educate yourself by looking at
other usenet postings and reading about usenet-netiquette.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 25 '05 #13
Is it Ok now? i just wasn't enrolled to the group

Oct 25 '05 #14
ba****@gmail.com said the following on 10/25/2005 10:35 AM:
This is my firt time here. i wasn't sure on how to reply.


Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?

Oct 25 '05 #15
Compiled sourcecode is not sourcecode anymore. You mean executable? Yes,i meant executable. Please first answer my Q on what platform.

Everything i use is local. I need to write an Html file (call it #1)
that
searches for a different html file (call it #2) that exist at them same
directory. if it exist it creates a link to in,and if not i should
execute a C file that will generate the #2 file.

My probem is - i don;'t know how to search for a file (tryed
JavaScript,didn't work) and how to execute a file from Html.

Thanks ! i hope i post it correctly this time.

Oct 25 '05 #16
Compiled sourcecode is not sourcecode anymore. You mean executable? Yes,i meant an executable file.
Please first answer my Q on what platform.


Everything i use is local. I need to search for html file #2
which is at the same library as html file #1.
if the html file #2 doesn;t exist,the html file #1 should excute a C
file
to create it.
Thanks,i hope i post is wright.

Oct 25 '05 #17
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In article <11**********************@z14g2000cwz.googlegroups .com>,
"batels" <ba****@gmail.com> writes:
[...]
Everything i use is local. I need to write an Html file (call it #1)
that
searches for a different html file (call it #2) that exist at them same
directory. if it exist it creates a link to in,and if not i should
execute a C file that will generate the #2 file.

My probem is - i don;'t know how to search for a file (tryed
JavaScript,didn't work) and how to execute a file from Html.
If I'm understanding you correctly, you basically can't do that.

I assume that what you want to do is:

1. When a page is loaded, a chunk of Javascript on the page looks to see
if other pages are available, and if they do create links to them
(this is doable, although quite hard);
2. If one of these pages doesn't exist, create it (this can't be done
the way you describe).

Remember that you don't have files. You have pages, which are given to you
by the server. The HTML is displayed by the browser, and any Javascript is
executed *on the browser* --- and it can't execute stuff on the server. All
it can do is to ask the server to do something (by getting a
specially-named page, or doing a POST) and the server does it from there.

You can do (1) by using something like XMLHTTPRequest to attempt to fetch a
web page. That'll let you see if it succeeds or not. I'd recommend against
it, though, because it's slow and uses lots of bandwidth. (Every time the
page is loaded, it's going to try and load lots of other pages, which have
to be pulled over the 'net.)

You can do (2), but not the way you describe. What you have to do here is
to set up a CGI script on the server to create the page, and then your
Javascript can tell the server to execute the script via XMLHTTPRequest
again.

Basically, I don't think Javascript is the right tool for solving your
problem. Unless there are other reasons why this *has* to be done in
Javascript, your best bet is to use a script running on the server written
in PHP or Perl or some such thing.
Thanks ! i hope i post it correctly this time.


Yup, much improved. Ta.

- --
+- David Given --McQ-+ "I concluded from the beginning that this would be
| dg@cowlark.com | the end; and I am right, for it is not half over
| (dg@tao-group.com) | yet." --- Sir Boyle Roche
+- www.cowlark.com --+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDXmeHf9E0noFvlzgRAsxYAJ98+WYJj0djDD/KD42JDNaYL0OuuACfWQZI
LZ+mR7xX9mO9JxKFON8mcyo=
=higU
-----END PGP SIGNATURE-----
Oct 25 '05 #18

Basically, I don't think Javascript is the right tool for solving your
problem. Unless there are other reasons why this *has* to be done in
Javascript, your best bet is to use a script running on the server written
in PHP or Perl or some such thing.


Thanks! it doesn't have to be JavaScript. I'll try to investigate
PHP,since
i'm not familiar with that.
Just one last thing,can i write a script in PHP that searches and
execute files
that are on my local pc and not saved on a server?

Oct 25 '05 #19
JRS: In article <11**********************@g47g2000cwa.googlegroups .com>
, dated Tue, 25 Oct 2005 07:35:44, seen in news:comp.lang.javascript,
ba****@gmail.com posted :
This is my firt time here. i wasn't sure on how to reply.


Before posting to a group, you should look round. There is a FAQ
posting three times a week, in two parts. Read both parts.

<FAQENTRY> To reply in Google, use Show Options then its Reply.
<FAQENTRY> For non-Web use, see the Microsoft newsgroups : *.jscript

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Oct 25 '05 #20
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In article <11**********************@g14g2000cwa.googlegroups .com>,
"batels" <ba****@gmail.com> writes:
[...]
Thanks! it doesn't have to be JavaScript. I'll try to investigate
PHP,since
i'm not familiar with that.
Just one last thing,can i write a script in PHP that searches and
execute files
that are on my local pc and not saved on a server?


No, you can't --- PHP scripts run on the server. The only way they could
run anything on the local machine is by sending a request to the user's
browser to do it, and nobody's browser should *ever* do that (because it's
a huge security hole).

- --
+- David Given --McQ-+ "I concluded from the beginning that this would be
| dg@cowlark.com | the end; and I am right, for it is not half over
| (dg@tao-group.com) | yet." --- Sir Boyle Roche
+- www.cowlark.com --+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDX1Dff9E0noFvlzgRAvEHAKDUCYmW/g0gUjcvNYtJ++8G6PKyMgCaAybK
3apdjV9lr4WyMo4GgZYpdHM=
=QhYh
-----END PGP SIGNATURE-----
Oct 26 '05 #21
David Given wrote:
[...]
"batels" <ba****@gmail.com> writes:
[...]
Thanks! it doesn't have to be JavaScript. I'll try to investigate
PHP,since
i'm not familiar with that.
Just one last thing,can i write a script in PHP that searches and
execute files
that are on my local pc and not saved on a server?
No, you can't --- PHP scripts run on the server.


Rubbish. PHP is but a programming language, it can run both
client-side and server-side. And so is and does J(ava)Script.
- --
+- David Given --McQ-+ "I concluded from the beginning that this would be
| dg@cowlark.com | the end; and I am right, for it is not half over
| (dg@tao-group.com) | yet." --- Sir Boyle Roche
+- www.cowlark.com --+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDX1Dff9E0noFvlzgRAvEHAKDUCYmW/g0gUjcvNYtJ++8G6PKyMgCaAybK
3apdjV9lr4WyMo4GgZYpdHM=
=QhYh
-----END PGP SIGNATURE-----


From someone with a (here discouraged) PGP signature one would expect such
basic knowledge. The signature itself is broken, though; it has to be
start with a line containing only "-- " to comply to Internet standards,
and it is recommended to keep it short (4 lines or less is quasi-standard).
PointedEars
Oct 26 '05 #22


From: Evertjan.
wrote on 25 okt 2005 in comp.lang.javascript:
All local. JavaScript on a local html page


Sorry,
if you persist in using usenet as email by not quoting where you are
replying on, so that others cannot follow the read,
I will not anwer you anymore.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


Evertjan. I am startled by how rude you are.

Obviously this person is a newbie and is 1) appropriately asking for
advice 2) stating what he/she has already done to look into the problem
3) thanking the group for any assistance they may provide. Your response
on the phrasing of the "Q" was neither helpful nor friendly.

Why would you respond in such a nasty manner?

You stated: "This is not sms, please use only usenet abbreviations. " If
you persist in thinking that this newsgroup is only available through
old-school programs or quasi-usenet through Google that provide a proper
quoting method, then you are denying the repurposing of information on
the Internet. I am currently replying through a textbox at
http://www.developersdex.com. There is no quoting, just a textbox.
(technically, a textarea, since you seem to be hung up on
technicalities) You're right, this is not sms, but it's not really
usenet either anymore, when I'm getting the information from http and
replying through http.

Likewise, your "replace all crosses…" statement is useless, because this
web page does not show your email address at all. Should I consider you
as stupid for your ill-advised tagline instruction?

The phrase is: "If you can't say something productive, keep your
friggin' mouth shut."
With that in mind, I will productively tell you to please refrain from
bashing someone when they are simply looking for help. You are not
helping.

Thanks in advance, <-- certainly in advance, since your first post
snidely said, "[We didn't do anything yet, so why the thanks.]"
Apparently "common courtesy" is not in your usenet vocabulary.
Jenn
*** Sent via Developersdex http://www.developersdex.com ***
Nov 4 '05 #23
Jenn M said the following on 11/4/2005 12:38 PM:

From: Evertjan.
wrote on 25 okt 2005 in comp.lang.javascript:

All local. JavaScript on a local html page

Sorry,
if you persist in using usenet as email by not quoting where you are
replying on, so that others cannot follow the read,
I will not anwer you anymore.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Evertjan. I am startled by how rude you are.


Jenn, I am startled by how ignorant you are.
Obviously this person is a newbie and is 1) appropriately asking for
advice
And they got advice.
2) stating what he/she has already done to look into the problem
True.
3) thanking the group for any assistance they may provide. Your response
on the phrasing of the "Q" was neither helpful nor friendly.
Depends on your perspective I guess.
Why would you respond in such a nasty manner?
This is Usenet, not your personal help desk. You don't like the
responses? Don't read them. Move on.
You stated: "This is not sms, please use only usenet abbreviations. "
I saw no reference by Evert to sms. But I did see Evertjan explain about
a few Newsreaders. Had the headers been looked at, it is obvious the OP
was posting from Google Groups and the directions to explain how to
quote the preferred way from Google is posted here almost daily.
If you persist in thinking that this newsgroup is only available through
old-school programs or quasi-usenet through Google that provide a proper
quoting method, then you are denying the repurposing of information on
the Internet.
Nobody ever alluded to it being only available through.... This is
Usenet. Not some half-baked web forum.

I am currently replying through a textbox at http://www.developersdex.com.
There is no quoting, just a textbox.
Then you need a better source of access/reply.
(technically, a textarea, since you seem to be hung up on
technicalities) You're right, this is not sms, but it's not really
usenet either anymore, when I'm getting the information from http and
replying through http.
Yes it is. http>Usenet and Usenet>http. How you post is irrelevant, you
are still posting to a Usenet newsgroup. The fact you are using a web
based interface is irrelevant.

Even developersdex says so.
<quote>
We have Over 90 usenet newsgroups available to search or post to.
</quote>
That is from the main page.

Likewise, your "replace all crosses…" statement is useless, because this
web page does not show your email address at all. Should I consider you
as stupid for your ill-advised tagline instruction?
Then you need a better method of access.
The phrase is: "If you can't say something productive, keep your
friggin' mouth shut."
Practice what you preach then.
With that in mind, I will productively tell you to please refrain from
bashing someone when they are simply looking for help. You are not
helping.
If they learn from it, then it helped. If you disagree, you have that
right. But so does anybody else here have the right to reply any way
they want to.
Thanks in advance, <-- certainly in advance, since your first post
snidely said, "[We didn't do anything yet, so why the thanks.]"
Apparently "common courtesy" is not in your usenet vocabulary.


Agreed.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 5 '05 #24

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Leslaw Bieniasz | last post by:
Cracow, 3.01.2005 Hello, When opening a file stream in the append mode, either a new file is created (if a specified file does not exist), or an existing file is opened for adding stuff. Is...
2
by: mike | last post by:
I had a form like below that validated that a file was there before it would submit. <form name="attach" method="POST" action="run_this_pgm.cfm" enctype="multipart/form-data"...
15
by: Geiregat Jonas | last post by:
is using if(open("file",O_EXCL) != -1){ printf("File does exists")}else{printf("file does not exists"); } a good way of checking if a file exists or not, if not how should I do it ?
26
by: Army1987 | last post by:
Is this a good way to check wheter a file already exists? #include <stdio.h> #include <stdlib.h> int ask(const char *prompt); typedef char filename; int main(int argc, char *argv) { FILE...
13
by: darkslide | last post by:
Hi, I'm checking if a file exists with the following code; If System.IO.File.Exists("C:\test.txt") = True Then MsgBox("File Exists") Else MsgBox("File Does Not Exist") End If ...
7
by: sprash | last post by:
Newbie question: I'm trying to determine if a file physically exists regardless of the permissions on it Using File.Exists() returns false if it physically exists but the process does not...
1
by: sitko | last post by:
Hi, I've created a program that opens a bit map and scans the pixels to count up the non-white pixels. I put the initial open function inside of a try statement, but it fails to hit an error if...
4
by: winningElevent | last post by:
Hi everyone, I have a question would like to ask. So far I know how to retrieve files from device, but sometimes device takes so long to produce file so I want my desktop to keep checking every...
4
by: ndedhia1 | last post by:
Hi. I am writing a java program in which I want to ftp a file to another unix box. First I have to check if the directory exists in which I am ftping into and if it does not exist, I have to create...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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
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
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
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...

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.