![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hello!, I have been using debian based GNU/linux for a few years now and have recently started using more complex shell scripts, I have a few questions that have been causing me issue during the last few days:
1: How to tell the file name of the current shell script? 2: How do I run A program/script from another directory but make it run from the directory that it lives in, EX: ~/script1.sh starts ~/randomdir/script2.sh will tell me that's it cant find dependent.txt witch is in ~/randomdir/ ? 3: I have A LAMP server running on my desktop, I would like to start qemu from a web front end, how do I start a program from a PHP/pyton/perl(I use PHP the most) that will run on my desktop? Thank you for your help in advance. |
|
||||
|
The current script's name is in $0 but it only basically tells you the path the user typed in (or how some tool resolved it), not necessarily the full path.
If your dependent script wants to load a library from a particular directory, you need to hard-code the path, or employ some heuristics to divine how you were invoked. $0 can be helpful but if the script is on the user's PATH then you need to start guessing. Perhaps the simplest solution is to require the user to set an environment variable to tell where the library can be found, or always run the script in a particular directory (yeah, not very elegant). Generally you don't want web visitors to be able to start programs on your desktop. Some web-facing programs go to great lengths to get an X11 client into a position where it can be driven by a CGI script and not get stuck, and under no circumstances be able to touch the local file system or other local resources. But if you are okay with the possible consequences, the main hurdle is probably getting xauth etc torn down to the point where your X11 is completely insecure, so that another user can start programs on your display. It may not really require more than xhost +localhost (after you put your helmet and your rubber gloves on). (Or do you mean "desktop computer" rather than "graphical session"?) Last edited by era; 04-27-2008 at 06:57 PM.. Reason: On enabling X11 from the web |
|
||||
|
Thank you for the fast reply! The HTTP is only accessible from 127.0.0.1, well that port neway. Would running apace2 from my user help me at all? I'm trying to avoid using gtk+ and stick with what I know(PHP/java script/CSS/ect).
Last edited by wmantly; 04-27-2008 at 07:05 PM.. Reason: reformated post |
|
||||
|
Like I wrote before, the main hurdle is really tearing down the X11 security features; even as yourself, you cannot easily start a program in another session until you have xauth cookies etc set up (or disabled).
Doing it from a CGI script is probably under no circumstances going to be easier than doing it from an interactive session. Work it out from the command line first, then see if you can make it run from inside the web server. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|