another cgi and shell scripting problem + webserver
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
another cgi and shell scripting problem + webserver
can someone give me some information about this...
what i'm trying to do is: i put up a webserver with a form on the webpage for filling in your name. When submitting that, i would like to run a cgi script with the given name as input in linux shell commandos that looks up your ID. Then i'd like to show that ID on the webpage.
How do i do that? i have created a form and the script. I googled a bit but couldn't find out how to give the ID back and put it in html.
Also, how do i use the given name in the script? e.g. when the form has <input type="text" id="yourname">, do i have to use $yourname?
i learned a lot of cgi and shell scripting today myself :-)
david, i will explain a bit more. i have a webserver with cgi running. When a client enters his hostname, id and password in a form on the website, the webserver (being front end of a dns server) updates some configuration files and also updates the webserver.
I kinda find out today how to get it fixed.
But i still have some shell scripting problems:
1. i can type in the command: cat /myfile | grep $FORM_hostname | cut -d" " -f4
which means i have a file with records in it in the form of (hostname ipaddress id otherinfo) and i want to check the <otherinfo> belonging to some hostname the user gave as input. that <otherinfo> is the info the webserver will show to the browser.
But i cannot put this in my shell scripting file, it gives errors. How can i echo this <otherinfo>? it must be possible ..
2. there are some others, but i'm not at home right now and can't come up immediately with them.
What are the other errors? I know that when I used CGI, that I had some problems with the PATH. The CGI-program was not always executed where is was located.
Perhaps you should try to use absolute paths to the files.
i should probably have picked perl indeed :-)
although i have some knowledge of perl i choose something new for me: cgi with shell scripting.
suprisingly retrieving the data from the input (a form) is simple if you use proccgi (i downloaded the proccgi.sh script and it works great).
but concerning shell scripting i have some new questions!:
1. im using /bin/sh. Now i have the following problem: in a while loop (while read LINE) I want to save the right line in a variable (so for one specific LINE : rightLine=$LINE ). Now i have to use $rightline later on, but this is not possible because rightline is a local variable of the loop. I dont know what to do now, i have to use the right line later in my script. Does someone know workarounds for this?
2. how to make files in a cgi script. I always get 'permission denied'. My script needs -rwxrwxrwx. A solution might be to make the file also -rwxrwxrwx (im not sure), but if this works, how can i do that. In commands: i want: echo "foo" > myFile.log (this gives me the permission denied error).
2.1 a similar problem is that i want to read information from a file which is -rwx------ or so. when i want to read information from such a file and write it in another one with probably less permissions i get this error.
2.2 another one is: i want to execute the ipsec command from a script: 'ipsec auto --add myConnection'. But this seems to be a command that only root may do. How to solve this.
The problem that always comes back is that i think that a cgi-script runs as a normal user and not as root. Is it possible to let the cgi script run as root?
3. what command can i use for testing whether a string is contained in some other string. I want to use it like this:
if [ "lo" in "hello everyone" ] //i dont know a command to do this in the shell
who can tell me what the if-condition must look like?