Connecting Tech Pros Worldwide Forums | Help | Site Map

Checking if a file exist

batels@gmail.com
Guest
 
Posts: n/a
#1: Oct 25 '05
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!


Evertjan.
Guest
 
Posts: n/a
#2: Oct 25 '05

re: Checking if a file exist


wrote on 25 okt 2005 in comp.lang.javascript:[color=blue]
> Hey All,[/color]

Not my name,
[color=blue]
> 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.[/color]
[color=blue]
> Can u advice?[/color]

This is not sms, please use only usenet abbreviations.
[color=blue]
> and once i know that file doesn't exist,can i call to a C file from a
> simple html page?[/color]
[color=blue]
> Thanks a lot![/color]

[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)

David Dorward
Guest
 
Posts: n/a
#3: Oct 25 '05

re: Checking if a file exist


batels@gmail.com wrote:
[color=blue]
> I'm writing an HTML page that needs to check if another html file exist[/color]

HTML is a data format, it can't "do" anything.
[color=blue]
> (in the same folder) and if not,to call to a C file and create that
> html file.[/color]

Call to a C file? Do you mean "execute a binary created by compiling
source C source code"?
[color=blue]
> I tryed to do that with JavaScript but i understood there is no such
> option.[/color]

Client side JavaScript runs with very low permissions. Its almost
certainly the wrong tool for what you are doing.
[color=blue]
> Can u advice?[/color]

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/

Cr1spy
Guest
 
Posts: n/a
#4: Oct 25 '05

re: Checking if a file exist


You could use the ActiveX scripting object, but I don't recomend it!

do a search on:

ActiveXObject("Scripting.FileSystemObject")

IE only though...

"Evertjan." <exjxw.hannivoort@interxnl.net> wrote in message
news:Xns96FAA30E6E851eejj99@194.109.133.242...[color=blue]
> wrote on 25 okt 2005 in comp.lang.javascript:[color=green]
>> Hey All,[/color]
>
> Not my name,
>[color=green]
>> 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.[/color]
>[color=green]
>> Can u advice?[/color]
>
> This is not sms, please use only usenet abbreviations.
>[color=green]
>> and once i know that file doesn't exist,can i call to a C file from a
>> simple html page?[/color]
>[color=green]
>> Thanks a lot![/color]
>
> [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)
>[/color]


batels@gmail.com
Guest
 
Posts: n/a
#5: Oct 25 '05

re: Checking if a file exist


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...

Evertjan.
Guest
 
Posts: n/a
#6: Oct 25 '05

re: Checking if a file exist


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

[please always quote on usenet, this is not email]
[color=blue]
> 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...[/color]

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)

batels@gmail.com
Guest
 
Posts: n/a
#7: Oct 25 '05

re: Checking if a file exist


Sorry for the english. I ment an executable C file.

batels@gmail.com
Guest
 
Posts: n/a
#8: Oct 25 '05

re: Checking if a file exist


All local. JavaScript on a local html page

Evertjan.
Guest
 
Posts: n/a
#9: Oct 25 '05

re: Checking if a file exist


wrote on 25 okt 2005 in comp.lang.javascript:
[color=blue]
> All local. JavaScript on a local html page
>[/color]

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)

batels@gmail.com
Guest
 
Posts: n/a
#10: Oct 25 '05

re: Checking if a file exist


This is my firt time here. i wasn't sure on how to reply.

Evertjan.
Guest
 
Posts: n/a
#11: Oct 25 '05

re: Checking if a file exist


wrote on 25 okt 2005 in comp.lang.javascript:
[color=blue]
> This is my firt time here. i wasn't sure on how to reply.[/color]

you are not learning!

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

batels@gmail.com
Guest
 
Posts: n/a
#12: Oct 25 '05

re: Checking if a file exist


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?

Evertjan.
Guest
 
Posts: n/a
#13: Oct 25 '05

re: Checking if a file exist


wrote on 25 okt 2005 in comp.lang.javascript:[color=blue]
> 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?[/color]

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)

batels
Guest
 
Posts: n/a
#14: Oct 25 '05

re: Checking if a file exist


Is it Ok now? i just wasn't enrolled to the group

Randy Webb
Guest
 
Posts: n/a
#15: Oct 25 '05

re: Checking if a file exist


batels@gmail.com said the following on 10/25/2005 10:35 AM:
[color=blue]
> This is my firt time here. i wasn't sure on how to reply.
>[/color]

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?

batels
Guest
 
Posts: n/a
#16: Oct 25 '05

re: Checking if a file exist


[color=blue]
> Compiled sourcecode is not sourcecode anymore. You mean executable?[/color]
Yes,i meant executable.[color=blue]
> Please first answer my Q on what platform.[/color]
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.

batels
Guest
 
Posts: n/a
#17: Oct 25 '05

re: Checking if a file exist


[color=blue]
> Compiled sourcecode is not sourcecode anymore. You mean executable?[/color]
Yes,i meant an executable file.
[color=blue]
> Please first answer my Q on what platform.[/color]

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.

David Given
Guest
 
Posts: n/a
#18: Oct 25 '05

re: Checking if a file exist


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In article <1130257921.185965.179080@z14g2000cwz.googlegroups .com>,
"batels" <batels@gmail.com> writes:
[...][color=blue]
> 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.[/color]

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.
[color=blue]
> Thanks ! i hope i post it correctly this time.[/color]

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-----
batels
Guest
 
Posts: n/a
#19: Oct 25 '05

re: Checking if a file exist



[color=blue]
> 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.[/color]

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?

Dr John Stockton
Guest
 
Posts: n/a
#20: Oct 25 '05

re: Checking if a file exist


JRS: In article <1130250944.839527.108140@g47g2000cwa.googlegroups .com>
, dated Tue, 25 Oct 2005 07:35:44, seen in news:comp.lang.javascript,
batels@gmail.com posted :[color=blue]
>This is my firt time here. i wasn't sure on how to reply.
>[/color]

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.
David Given
Guest
 
Posts: n/a
#21: Oct 26 '05

re: Checking if a file exist


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In article <1130267937.358137.246720@g14g2000cwa.googlegroups .com>,
"batels" <batels@gmail.com> writes:
[...][color=blue]
> 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?[/color]

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-----
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#22: Oct 26 '05

re: Checking if a file exist


David Given wrote:
[color=blue]
> [...]
> "batels" <batels@gmail.com> writes:
> [...][color=green]
>> 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?[/color]
>
> No, you can't --- PHP scripts run on the server.[/color]

Rubbish. PHP is but a programming language, it can run both
client-side and server-side. And so is and does J(ava)Script.
[color=blue]
> - --
> +- 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-----[/color]

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
Jenn M
Guest
 
Posts: n/a
#23: Nov 4 '05

re: Checking if a file exist




From: Evertjan.
wrote on 25 okt 2005 in comp.lang.javascript:
[color=blue][color=green]
> > All local. JavaScript on a local html page
> >[/color]
>
> 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)[/color]

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 ***
Randy Webb
Guest
 
Posts: n/a
#24: Nov 5 '05

re: Checking if a file exist


Jenn M said the following on 11/4/2005 12:38 PM:
[color=blue]
>
> From: Evertjan.
> wrote on 25 okt 2005 in comp.lang.javascript:
>
>[color=green][color=darkred]
>>>All local. JavaScript on a local html page
>>>[/color]
>>
>>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)[/color]
>
>
> Evertjan. I am startled by how rude you are.[/color]

Jenn, I am startled by how ignorant you are.
[color=blue]
> Obviously this person is a newbie and is 1) appropriately asking for
> advice[/color]

And they got advice.
[color=blue]
> 2) stating what he/she has already done to look into the problem[/color]

True.
[color=blue]
> 3) thanking the group for any assistance they may provide. Your response
> on the phrasing of the "Q" was neither helpful nor friendly.[/color]

Depends on your perspective I guess.
[color=blue]
> Why would you respond in such a nasty manner?[/color]

This is Usenet, not your personal help desk. You don't like the
responses? Don't read them. Move on.
[color=blue]
> You stated: "This is not sms, please use only usenet abbreviations. "[/color]

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.
[color=blue]
> 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.[/color]

Nobody ever alluded to it being only available through.... This is
Usenet. Not some half-baked web forum.

[color=blue]
> I am currently replying through a textbox at http://www.developersdex.com.
> There is no quoting, just a textbox.[/color]

Then you need a better source of access/reply.
[color=blue]
> (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.[/color]

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.

[color=blue]
> 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?[/color]

Then you need a better method of access.
[color=blue]
> The phrase is: "If you can't say something productive, keep your
> friggin' mouth shut."[/color]

Practice what you preach then.
[color=blue]
> 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.[/color]

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.
[color=blue]
> 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.[/color]

Agreed.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Closed Thread