LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-11-2011, 07:49 AM   #1
joost1
LQ Newbie
 
Registered: Mar 2011
Posts: 5

Rep: Reputation: 0
QNX checksum call in cgi shell scripting not working


Hi all,

I'm new to linux and to cgi shell scripting. I have a QNX machine with a slinger webserver running on it. With a cgi script i'm trying to do the QNX cksum call and compare it's output value with a fixed output.

When i execute the script at the command line it works perfect, but when execute this script by by the webserver in my browser it doesn't work. Here's my code:

#!/bin/sh

FILE="/home/checkfile"
ORIGCHECK="1712885500"

temp=`cksum $FILE | cut -f 1 -d ' '`

echo $temp
if [ $temp = $MATCHING ]
then
echo "Checksums are matching"
else
echo "Checksums NOT matching"
fi


Could it be possible that i'm not allowed to do the cksum call in combination with the slinger webserver? Can someone help me solve this problem?

Thanks in advance
 
Old 03-11-2011, 06:31 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
You are using a variable '$MATCHING' that doesn't seem to be initialized anywhere. Do you really mean to use
Code:
#!/bin/sh
FILE="/home/checkfile"
ORIGCHECK="1712885500"

temp=`cksum $FILE | cut -f 1 -d ' '`

echo $temp
if [ $temp = $ORIGCHECK ]
then
    echo "Checksums are matching"
else
    echo "Checksums NOT matching"
fi
This is not nearly complete enough to be a CGI. There is no output of HTTP headers, or any HTML.

You give the classic 'it doesn't work' description of the fault. Can you add a whole bunch of detail to that?

--- rod.

Last edited by theNbomr; 03-11-2011 at 06:33 PM.
 
Old 03-14-2011, 02:54 AM   #3
joost1
LQ Newbie
 
Registered: Mar 2011
Posts: 5

Original Poster
Rep: Reputation: 0
Tnx for your reply Rod.

I'm sorry i tried so many things and i made some mistakes setting the code in the old back to how it first was. I didn't post the html tags in the code because i thought it wasn't very usefull here. This is my complete code:

#!/bin/sh
echo "Content-type: text/html"

echo

echo "<html>"
echo "<head>"
echo "<title>Checksum test</title>"
echo "</head>"
echo "<body>"

FILE="/home/engineer/checkfile"
ORIGCHECK="1696368580"

TEMP=`cksum $FILE | cut -f 1 -d ' '`
RETURNVALUE=$?
echo $RETURNVALUE

echo $TEMP
if [ $TEMP = $ORIGCHECK ]
then
echo "Checksums are matching"
else
echo "Checksums NOT matching"
fi

echo "</body>"
echo "</html>"


This is the output i get when i run the CGI-script at the command line:

Content-type: text/html

<html>
<head>
<title>Checksum test</title>
</head>
<body>
0
1696368580
Checksums are matching
</body>
</html>



And here is the html source when i run this script in the webbrowser:
<html>
<head>
<title>Checksum test</title>
</head>
<body>
126

Checksums NOT matching
</body>
</html>


It seems i get a 126 error return code when i run this in the webbrowser.
I hope you can help me further with this.
 
Old 03-14-2011, 03:49 AM   #4
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
The PATH environment variable is not available when your CGI script is being run. Try this at the command line:
Code:
which cksum
which cut
Let's say, for example, that your output is:
Code:
/usr/bin/cksum
and
Code:
/usr/bin/cut
Then in your script, say /usr/bin/cksum instead of just cksum, and /usr/bin/cut instead of just cut.
 
Old 03-14-2011, 06:39 AM   #5
joost1
LQ Newbie
 
Registered: Mar 2011
Posts: 5

Original Poster
Rep: Reputation: 0
Thank you, that helped a lot.

Now i only have to solve some rights issues.
Got permission denied when i use the shell commands through the webserver, but this looks doable.

Last edited by joost1; 03-14-2011 at 06:41 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cgi shell script: ssh not working kitmui Programming 2 04-21-2010 02:46 PM
Call CGI w/POST variables from shell matthewo256 Red Hat 1 06-16-2009 10:53 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
cgi and shell scripting, setting it up? GridX Programming 7 04-12-2004 11:01 PM
another cgi and shell scripting problem + webserver prinski Programming 6 04-08-2004 04:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration