473,246 Members | 1,593 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,246 software developers and data experts.

Unix path in Javascript

Hi,
I am new to Javascript and I developed a code and one of the functions needs a path (a directory location) as its input. It works fine for all windows paths
get _path("c:/somedir/somedir") but when i transfered this file on to a unix system and when I replace this path with a unix path it does not work. I am very sure I am giving the wrong path format. I tried all the possible ways, I am not sure what is missing.
Expand|Select|Wrap|Line Numbers
  1. get_path(".:/bin/somedir");
  2. get_path("/bin/somedir");
  3. get_path("./bin/somedir");
  4. get_path("\bin\somedir");
I tried all the above and non of them work. Please help me figure out the right path format.
Sep 9 '07 #1
9 2814
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

What does get_path do? Can you show the code for it?
Sep 10 '07 #2
Welcome to TSDN!

What does get_path do? Can you show the code for it?
Hi,
get_path() is just some sample name I used to identify a method. But any way my function is this

Expand|Select|Wrap|Line Numbers
  1. function ShowHomeFolderContents(){
  2.     var f = fs.GetFolder("C:/workspace");
  3. /* In unix var f= fs.GetFolder("/bin/out/test"); but this does not work */
  4.     var fc = new Enumerator(f.files);
  5.     var path = " ";                
  6.  
  7.     for (; !fc.atEnd(); fc.moveNext()) 
  8.     { 
  9.     //dispaly the folder names
  10.                 document.write(fc.item() )            
  11.     }     
  12. }
So it works fine for all windows path and not for unix path on an unix system. I am very sure its the path format.
Sep 10 '07 #3
acoder
16,027 Expert Mod 8TB
It seems like you're using ActiveX and not normal Javascript. ActiveX only works in Internet Explorer. That's probably what's causing the problem. Standard Javascript does not allow you to access the local file system.
Sep 10 '07 #4
It seems like you're using ActiveX and not normal Javascript. ActiveX only works in Internet Explorer. That's probably what's causing the problem. Standard Javascript does not allow you to access the local file system.
Thank you for your reply ..
I am really new and i am not sure, what you mean by using ActiveX and not Javascript and also why Javascript does not allow to access the local file system because it does allow me to access the windows file system.
Here is what I have
I have a .html file and a .js file. All my java functions are in the .js file. My .html call this .js file and it runs fine in windows when I write this function 'fs.GetFolder("C:/workspace");' But when i copied these files on to my other Unix machine and run the same .html (which calls the .js file) its just displays the html contents and not the output of the java functions. I am using alert statements to see the flow in my java code. And it stops at the same function with an unix path 'fs.GetFolder("/bin/opt/dir/");' So i am sure I am not using the correct unix path format.
Sep 10 '07 #5
acoder
16,027 Expert Mod 8TB
Post the rest of your code or a link.
Sep 10 '07 #6
Post the rest of your code or a link.
Ok, below is my Javascript file contents (file name: javaScript.js)

Expand|Select|Wrap|Line Numbers
  1. var fs = new ActiveXObject("Scripting.FileSystemObject");
  2. function ShowHomeFolderContents(){
  3.     var f = fs.GetFolder("C:/");
  4.     var fc = new Enumerator(f.files);
  5.     var path = " ";                
  6.  
  7.     for (; !fc.atEnd(); fc.moveNext()) 
  8.     { 
  9.     path = fc.item(); 
  10.     document.write(path+"<br>");                    }     
  11. }
  12.  
And below is my html (file name tree1.htm)

[HTML]<html>
<head>
<title>JavaScript Tree Control</title>
<style>
body {
font: 10pt Verdana, sans-serif;
color: navy;
}

.trigger {
cursor: pointer;
cursor: hand;
}

.branch {
display: none;
margin-left: 16px;
}
</style>
<script type="text/javascript" src="javaScript.js"></script>
</head>
<body>
<script type="text/javascript"> ShowHomeFolderContents()</script>
</body>
</html>[/HTML]

I want to copy this code to a unix machine and change the directory path in the function (var f = fs.GetFolder("C:/");) from C:/ to an unix directory path. And I am using IE to view the output. I just want to know how to substitute the dir path in unix. I hope you understand what I am trying to do.
Sep 10 '07 #7
acoder
16,027 Expert Mod 8TB
Have a look at the first line - it uses ActiveXObject. This is supported in IE only.

To prove this, download another browser such as Firefox, Opera, Netscape, etc. on Windows and try out your code. It won't work.
Sep 11 '07 #8
Have a look at the first line - it uses ActiveXObject. This is supported in IE only.

To prove this, download another browser such as Firefox, Opera, Netscape, etc. on Windows and try out your code. It won't work.
I Understand that it does not work with other browsers, but how will this help me with the unix path when I copy the Html and my JS files on to my unix server ?. Note: I will open with an IE on the client side.
OR do you mean to say that since it works only on IE, it will not work on the unix machine. But if thats the case then I am using IE on my client machine to view and run these files. Please help me solve my UNIX Path Problum.
Sep 11 '07 #9
acoder
16,027 Expert Mod 8TB
I Understand that it does not work with other browsers, but how will this help me with the unix path when I copy the Html and my JS files on to my unix server ?. Note: I will open with an IE on the client side.
OR do you mean to say that since it works only on IE, it will not work on the unix machine. But if thats the case then I am using IE on my client machine to view and run these files. Please help me solve my UNIX Path Problum.
This code will only work on IE. Unless you can somehow install IE in Unix, you can't get this code to work in Unix.
Sep 11 '07 #10

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

Similar topics

3
by: dpackwood | last post by:
Hello, I have two different scripts that do pretty much the same thing. The main perl script is on Windows. It runs and in the middle of it, it then calls out another perl script that then...
1
by: Toralf Lund | last post by:
Is there any way at all I can get a user's login name from within JavaScript on Unix/Linux with Mozilla browser. If not, how about the home directory? I know there are *usually* variables...
3
by: alanrn | last post by:
I would like to start a dialog on how to implement the equivalent functionality of UNIX shared memory in .NET. I work with a factory automation system. The bulk of the system is written in C/C++....
4
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of...
1
by: eeriehunk | last post by:
Hi, 1.what if my Html and my script are on a unix server and I have to provide a unix path, what would the unix path format be? var f = fs.GetFolder(Server.MapPath("/bin/somedir/somedir/"); or can...
2
by: Javier | last post by:
Hello all, I'm trying to remove a hidden file (in UNIX) using the Boost::filesystem library. This is what I have: #include <boost/filesystem/operations.hpp> namespace...
0
by: =?Utf-8?B?QW5vbnltb3Vz?= | last post by:
I just posted this in microsoft.public.inetserver.iis but thought this might be a better place for it. I have the following ASP page that simply executes a DIR command on a UNC path and displays...
65
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but...
6
by: Marcin201 | last post by:
Is there an built-in functionality in python to convert Windows paths to Unix paths? I am running into problems when creating data files on Windows and the running them on a Unix platform. I...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.