In Objective-C, NSString has a method called
stringByExpandingTildeInPath
This method will take a string like "~/Documents" and resolve it to "/Users/Nick/Documents". The "~" tilde is resolved to the home directory of the current user of the machine the program is running on.
Now my question is this... I am writing a little FTP/SFTP utility using Cocoa and Objective-C. How could I resolve a tilde (~) path on remote machine via FTP/SFTP?
For example. A user wants to upload a file to
sftp://remote-host.com:~/
If remote-host.com is a Linux or OSX server, then this path is totally valid. However uploading a file only works when I specify the absolute path. I'm not sure if this is a limitation of the framework I'm using, ConnectionKit, or if this is something that I need to manually implement. I'm ok with the latter but, any suggestions on how?
You could try just removing the "~/" (and use the rest as a relative path) - generally the server should put you in the user's home directory by default when you connect.
Related
I want to edit files on my server, but don't want to always upload the files, is there a way on to edit the files remotly?
I tryed to make an bash script which should upload the files, but its not realy good :/ and sometimes didn't worked
You can use Atom with the
Retome FTP edit
Package
If you have got an SSH (SFTP enabled) access to your server, an option would be use use SSHFS to mount a remote directory on your local working path.
In this way you can use any editor (or even something else) to change your files and they will always be synchronised.
Just keep in mind that, in this way, files are actually located on your server, you won't have a real copy on your local machine.
I am trying to developing an App for QNAP. I am really noob about QNAP, so please help me!
I succeeded in creating a qpkg package and installing it correctly, and it works. But the problem arises when I want to give my app a web interface.
I have just a index.html file that just has an helloworld text inside.
I create the environment with the QDK and I have the /share/XXX_DATA/.qpkg/QDK/MyApp folder
Now, a part of the other files, I create
/share/XXX_DATA/.qpkg/QDK/MyApp/Web
and put there my index.html with my HelloWorld message.
Ok now, I modify the /share/XXX_DATA/.qpkg/QDK/MyApp/qpkg.cfg file and set the variable
QPKG_WEBUI="/MyApp/Web"
From the documentation, for example https://edhongcy.gitbooks.io/qdk-qpkg-development-kit/content/qpkg-configuration-file.html , I can see
QPKG_WEBUI
Relative path to installed application's web interface (the
specified path is relative the configured location of web server data;
usually /share/Web or /share/Qweb.) The specified path must start with
a '/'. The displayed link can only be accessed when the QPKG is
enabled. A default value of '/' is set automatically at installation
if QPKG_WEB_PORT has been given a value and QPKG_WEBUI is empty.
Then I also create a link in /share/XXX_DATA/Web folder to my web folder.
(the /share/Web is just a link to /share/XXX_DATA/Web)
That is:
ln -s /share/XXX_DATA/.qpkg/QDK/MyApp/shared/Web /share/XXX_DATA/Web/MyApp/Web
Well, what happens that now, I can open a Window in my QNAP when I click on "open" in my app but it is completely blank. I tried a lot of different variants but my window is allways blank.
Must I modify something more a part from the qpkg.cfg file?
Do you have some documentation with sample codes?
Is QPKG_WEBUI the correct variable to modify?
Thanks very much to everyone
After a carefully study of the problem, and after trying other applications with the same problem, I found the conclusion that the problem was not the QPKG_WEBUI variable.
The problem was that my QNAP web interface (I do not know if it is a general thing for every QNAP or only in my case) has as default port 8080, but the WEBUI have as default port 80.
Then it seems that the web browser blocks the WEBUI in the iframe inside the QNAP interface in order to follow the Same Origin Policy. When opened in a new window, the WEBUI works correctly.
Setting the QPKG_USE_PROXY=1 variable let the iframe work too.
I am running Python under WSGI on an Apache server using CentOS 6. The python script uses a wrapper for the NCAR library called PyNGL. The purpose of this library is to generate graphics from supplied data.
I am attempting to use my python script as a web service by hooking it up to web.py, but it has an entry point for direct execution as well.
Here is the weird thing:
When I run the script directly it works as intended and produces an output image in the directory of the script. However, when I attempt to invoke it through the web.py controller (with the exact same parameters) it fails.
My apache error log contains this:
warning:GKS:GCLRWK: -- cairo driver error: error opening output file
I'm guessing that this is probably a permissions problem, but I haven't the slightest idea where its trying to output.
Edit: I think I have confirmed that it is indeed a permissions error.
I attempted to create file using relative paths and got a similar error:
<type 'exceptions.IOError'> at /plot
[Errno 13] Permission denied: 'Output.txt'
This error refers to this line here:
with open("Output.txt", "w") as text_file:
text_file.write(str(self.__dict__))
Now of course I can specify an absolute path for that text file, but not for the graphical output from PyNGL. Is there a way to determine where it is trying to output, or to change the default output directory?
Usually your application would be running with the current working directory as '/'. The Apache user will not be able to write to that directory.
In any web application you should in general never rely on it being run in a specific directory as different web servers behave differently as to what the current working directory would be. If you assume it always runs in a specific directory, your application would be inherently unportable. Changing the working directory of an application to get around this is also in general bad practice because in a hosting mechanism that allows multiple application to run in the same process, they would all interfere with each other if they each tried to set their own working directory.
What you should do is always use absolute paths when reading and write files and not use relative paths. Why do you say you can't use absolute paths?
Also be aware that your application will run as a special user which would not have access to directories to create files. You would therefore need to open up access to the Apache user. Best practice would be to limit though what the Apache user can write to.
Now since you are using mod_wsgi, one viable option is to make sure you are using mod_wsgi daemon mode and when using the WSGIDaemonProcess directive set the 'home' option to override the current working directory for the single WSGI application delegated to that process. You can also set 'user' and 'group' options to have the process run as a different user that does have access to the directory.
I have made up a simple http server using libevent. The way the resource (folders in my case) are accessed is
http://serverAddress:port/path/to/resouce/
the path to resource is extracted using the decoded url . It works fine on Linux as request would be something like this
http://severAddress:port/home/vickey/folder
but on window$ request is
http://serverAddress:port/c:/users/vickey/folder
which results in decoded url as /c:/users/vickey/folder. Its manually possible to remove the leading slash to correct the problem. However since I m using and learning boost libraries in my code I was wondering if there was some implementation of this sort ? I tried using native() and relative_path(). Thanks.
Its definitely possible to do as you're asking, but I would suggest a different approach. How about creating a configuration property for the server which could be called RESOURCE_BASE_PATH. The resource path received in the URL would be appended to the RESOURCE_BASE_PATH to create the complete path.
This is pretty standard for FTP and HTTP servers and the like. On Windows, it could be set to "c:" and on Linux, left blank which would default to "/".
Also remember on Windows the slashes (\) are different than those on Unix (/).
I have a web application that runs fine locally, but when I move it to a virtual directory on the web server (let's call it "VirDir"), it adds the directory name to the relative path.
For example, if I try to access ~/Default.aspx, it will tell me that it cannot find /VirDir/VirDir/Default.aspx.
Is it something boneheaded, or do I just have to use absolute addressing to make it work (if I try to access /Default.aspx, it finds it fine)?
That's the way it is... Use absolute addressing as /default.aspx.
Might help explain your case:
http://forums.asp.net/t/1521537.aspx
Take a look here to better understand iis 6 and virtual directories:
http://msdn.microsoft.com/en-us/library/zwk103ab.aspx