The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-27-2008
wmantly wmantly is offline
Registered User
  
 

Join Date: Apr 2008
Location: NYC
Posts: 2
Question How to....

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.
  #2 (permalink)  
Old 04-27-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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
  #3 (permalink)  
Old 04-27-2008
wmantly wmantly is offline
Registered User
  
 

Join Date: Apr 2008
Location: NYC
Posts: 2
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
  #4 (permalink)  
Old 04-27-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0