By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,508 Members | 1,823 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,508 IT Pros & Developers. It's quick & easy.

Symbolic Link

P: n/a
I am trying to create a link to a file, which I can then use in an
HTML page.

The system is Linux on a hosted web service, running python 2.3.
Other than that I have no knowledge of the system.

The link is created OK, but when I try to use it as filename for the
IMG TAG, it does not get displayed. The page source of the created
page is pointing to the link as temp/test1.jpg

Any ideas ?

srcFile = "temp/test2.jpg"

linkFile = "temp/test1.jpg"

if os.path.islink(linkFile):
print "Link Exists", nl
pass
else:
print "Making Link", nl
os.symlink(srcFile, linkFile)

print '<BR><img src="%s">the image</IMG><BR><BR>' % linkFile

print '<img src="%s">the image</IMG>' % srcFile

Aug 18 '07 #1
Share this Question
Share on Google+
11 Replies


P: n/a
mosscliffe schrieb:
I am trying to create a link to a file, which I can then use in an
HTML page.

The system is Linux on a hosted web service, running python 2.3.
Other than that I have no knowledge of the system.

The link is created OK, but when I try to use it as filename for the
IMG TAG, it does not get displayed. The page source of the created
page is pointing to the link as temp/test1.jpg

Any ideas ?

srcFile = "temp/test2.jpg"

linkFile = "temp/test1.jpg"

if os.path.islink(linkFile):
print "Link Exists", nl
pass
else:
print "Making Link", nl
os.symlink(srcFile, linkFile)

print '<BR><img src="%s">the image</IMG><BR><BR>' % linkFile

print '<img src="%s">the image</IMG>' % srcFile
In what environment is that script running? If it's apache, it might be
that the apache settings disallow for following links.

Diez
Aug 18 '07 #2

P: n/a
On 18 Aug, 23:49, "Diez B. Roggisch" <de...@nospam.web.dewrote:
mosscliffe schrieb:
I am trying to create a link to a file, which I can then use in an
HTML page.
The system is Linux on a hosted web service, running python 2.3.
Other than that I have no knowledge of the system.
The link is created OK, but when I try to use it as filename for the
IMG TAG, it does not get displayed. The page source of the created
page is pointing to the link as temp/test1.jpg
Any ideas ?
srcFile = "temp/test2.jpg"
linkFile = "temp/test1.jpg"
if os.path.islink(linkFile):
print "Link Exists", nl
pass
else:
print "Making Link", nl
os.symlink(srcFile, linkFile)
print '<BR><img src="%s">the image</IMG><BR><BR>' % linkFile
print '<img src="%s">the image</IMG>' % srcFile

In what environment is that script running? If it's apache, it might be
that the apache settings disallow for following links.

Diez
It is Apache.

Can I create some override in the current directory. I am afraid my
Apache skills are almost zero.

Thanks

Richard

Aug 19 '07 #3

P: n/a
mosscliffe schrieb:
On 18 Aug, 23:49, "Diez B. Roggisch" <de...@nospam.web.dewrote:
>mosscliffe schrieb:
>>I am trying to create a link to a file, which I can then use in an
HTML page.
The system is Linux on a hosted web service, running python 2.3.
Other than that I have no knowledge of the system.
The link is created OK, but when I try to use it as filename for the
IMG TAG, it does not get displayed. The page source of the created
page is pointing to the link as temp/test1.jpg
Any ideas ?
srcFile = "temp/test2.jpg"
linkFile = "temp/test1.jpg"
if os.path.islink(linkFile):
print "Link Exists", nl
pass
else:
print "Making Link", nl
os.symlink(srcFile, linkFile)
print '<BR><img src="%s">the image</IMG><BR><BR>' % linkFile
print '<img src="%s">the image</IMG>' % srcFile
In what environment is that script running? If it's apache, it might be
that the apache settings disallow for following links.

Diez

It is Apache.

Can I create some override in the current directory. I am afraid my
Apache skills are almost zero.
As are mine. At least from the top of my head. You better ask in a more
apache-centric forum.

Diez
Aug 19 '07 #4

P: n/a
mosscliffe wrote:
I am trying to create a link to a file, which I can then use in an
HTML page.

The system is Linux on a hosted web service, running python 2.3.
Other than that I have no knowledge of the system.

The link is created OK, but when I try to use it as filename for the
IMG TAG, it does not get displayed. The page source of the created
page is pointing to the link as temp/test1.jpg
What are you trying to do that you can't use the original file instead
of creating a link? There might be a way to side-step the entire problem.
Aug 19 '07 #5

P: n/a
On 19 Aug, 13:16, samwyse <dejan...@email.comwrote:
mosscliffewrote:
I am trying to create a link to a file, which I can then use in an
HTML page.
The system is Linux on a hosted web service, running python 2.3.
Other than that I have no knowledge of the system.
The link is created OK, but when I try to use it as filename for the
IMG TAG, it does not get displayed. The page source of the created
page is pointing to the link as temp/test1.jpg

What are you trying to do that you can't use the original file instead
of creating a link? There might be a way to side-step the entire problem.
The source file is in an area which python can see, but not the
browser. I am trying to make a link in a browser friendly area so I
can use it to display an image file.

Thanks

Richard

Aug 19 '07 #6

P: n/a
On Aug 19, 4:29 pm, mosscliffe <mcl.off...@googlemail.comwrote:
The source file is in an area which python can see, but not the
browser. I am trying to make a link in a browser friendly area so I
can use it to display an image file.
You might want to try using an .htaccess file. Place a file
called .htaccess in the "browser friendly area" and place in it the
line:

Options +FollowSymLinks

Assuming your hosting service will allow that, then it should work.
If not, then why not just copy the image files? Storage is cheap
these days.

Hyuga

Aug 20 '07 #7

P: n/a
Hyuga wrote:
On Aug 19, 4:29 pm, mosscliffe <mcl.off...@googlemail.comwrote:
>The source file is in an area which python can see, but not the
browser. I am trying to make a link in a browser friendly area so I
can use it to display an image file.

You might want to try using an .htaccess file. Place a file
called .htaccess in the "browser friendly area" and place in it the
line:

Options +FollowSymLinks

Assuming your hosting service will allow that, then it should work.
If not, then why not just copy the image files? Storage is cheap
these days.

Hyuga
My question would be why a symbolic link? Why not a hard link? Are the
two directories on different mount points? After the script finishes
does python need to see that image file again? Why not just move it?

Ian

Aug 21 '07 #8

P: n/a
On 22 Aug, 00:05, Ian Clark <icl...@mail.ewu.eduwrote:
Hyuga wrote:
On Aug 19, 4:29 pm,mosscliffe<mcl.off...@googlemail.comwrote:
The source file is in an area which python can see, but not the
browser. I am trying to make a link in a browser friendly area so I
can use it to display an image file.
You might want to try using an .htaccess file. Place a file
called .htaccess in the "browser friendly area" and place in it the
line:
Options +FollowSymLinks
Assuming your hosting service will allow that, then it should work.
If not, then why not just copy the image files? Storage is cheap
these days.
Hyuga

My question would be why a symbolic link? Why not a hard link? Are the
two directories on different mount points? After the script finishes
does python need to see that image file again? Why not just move it?

Ian
I just imagined a symbolic link would be quicker.

I have tested a hard link now and it seems to work fine. I am
deleting the link/s at the end of the session/s.

I think a link is better than a move, because there is always a
possibility I might somehow delete the moved file and then I would
lose the original one.

Thanks for your help.

Richard

Aug 23 '07 #9

P: n/a
In message <ma*************************************@python.or g>, Ian Clark
wrote:
My question would be why a symbolic link? Why not a hard link?
Because of the potential for confusion. For instance, modifying the file
without realizing that some other place expects to see the unmodified
version.
Aug 31 '07 #10

P: n/a
mosscliffe wrote:
On 22 Aug, 00:05, Ian Clark <icl...@mail.ewu.eduwrote:
>>
>>>On Aug 19, 4:29 pm,mosscliffe<mcl.off...@googlemail.comwrote:

The source file is in an area which python can see, but not the
browser. I am trying to make a link in a browser friendly area so I
can use it to display an image file.

My question would be why a symbolic link? Why not a hard link? Are the
two directories on different mount points? After the script finishes
does python need to see that image file again? Why not just move it?

I have tested a hard link now and it seems to work fine. I am
deleting the link/s at the end of the session/s.
This is a bit late, but the reason the symbolic link won't work is
because it's the web-server that's resolving it. The browser can only
see things that the web-server, huh, serves, so what was meant in the
first paragraph above was that the web server couldn't access the file
in its original location. If you create a sym-link, the web server
opens the link, finds out the actual location of the file, and tries to
open that file, which it still can't do. A hard-link, OTOH, allows
direct access to the contents of a file, as long as it is on the same
filesystem. No extra steps are required, so the process runs a few
microseconds faster, and directory-level permissions can't get in the way.
Sep 10 '07 #11

P: n/a
In message <1o******************@newssvr11.news.prodigy.net >, samwyse wrote:
A hard-link, OTOH, allows
direct access to the contents of a file, as long as it is on the same
filesystem. No extra steps are required, so the process runs a few
microseconds faster, and directory-level permissions can't get in the way.
Hard links are best avoided, because of the confusion they can cause.
Sep 10 '07 #12

This discussion thread is closed

Replies have been disabled for this discussion.