Programming :: Argument Relations In CGI Script

Feb 15, 2010

I have made fallowing script for CGI scripting learning purpose:

Code:
#!/bin/sh
echo "Content-type: text/html"
echo
CMD='echo "$QUERY_STRING" | sed -n 's/^.*cmd=([^&]*).*$/1/p' | sed "s/%20/ /g" '
echo "<html>"
echo "<head><title>Hello CGI</title></head>"
echo "<body>" .....
echo "<input type=radio name=cmd value=ifconfig checked> ifconfig <br>"
echo "<input type=radio name=cmd value=uname> uname -a <br>"

This script works fine, but actually I quite don't understand it's inner working about those radio buttons.

View 1 Replies


ADVERTISEMENT

Ubuntu :: Write A Base Script Which Will Divide An Argument By 10 And Then Use That Argument In Another Program?

Feb 23, 2010

I'm trying to write a base script which will divide an argument by 10 and then use that argument in another program. Since my argument can be a floating point number, I used bc to accomplish this. Here's an example of a simplified version of what I have so far:

<code>NUM=$(echo "scale=25;$1/10" | bc)
#make sure the first argument was formatted correctly
if [ $? -ne 0 ]

[code]...

View 4 Replies View Related

Programming :: Insert $2 Argument Until The End To Variable?

May 17, 2011

how to insert $2 argument until the end to variable?For example:

>> cucu.csh user "long long message "
$1 = user
$2 = "long long message "

View 10 Replies View Related

Programming :: Making A 1 Command Line Argument?

Jun 8, 2010

I need to write a script that will take 1 command line argument. The argument will be a username. The script will determine if the user exists on the system and will print an error if it does not. If the user does exist it will determine if the user is currently logged in, if the user is not logged in it will determine the last time the user logged in and display the file in the users home directory that was most recently modified.

View 2 Replies View Related

Programming :: Passing The Char * Vector Argument?

Jun 19, 2010

I am trying to simulate a shell. So what I do is checking of having the parameters from standard input, suc as "/bin/ls -l /home/france/Documents", and then passing them to function execute, which at some point calls execvp(argv[0],argv)The problem is that I don't succeed in using these arguments, while if I call execvp(paramList[0],paramList) it works!!!! Where paramList is exactly what I would put on standard input, but defined statically.

Code:

#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

[code].....

View 2 Replies View Related

Programming :: [bash] Option Followed By Argument List?

Feb 6, 2010

I'd like to pass the following arguments to a bash script in any order:

Code:
myscript -l <country> -r <file1> <file2> ... -o

I read the argument list in a switch shift loop. I figured out how to read the filelist but only if -f is the last option.

how to position the file list anywhere in the argument list?

View 5 Replies View Related

Programming :: C - User To Input The Name Of A File As An Argument

Aug 5, 2010

Write a program that requires the user to input the name of a file as an argument. If the user fails to include one argument it should make use of a thread that handles a signal. The signal handler should tells the user Incorrect number of arguments and then calls the terminate signal on the process.

If the numbers of arguments are correct then the program should allocate memory space to the file (5MB) and create a child process that requests the user for a character that it should send to the parent. The child should keep request for data until the user keys in the character O. During each request it should pause for 10 seconds, send the character to the parent and then requesting again for another character.

The parent should get the character from the child. Do not make the parent wait for the child to finish requesting for data. Make use of pipes to facilitate communication between the parent and the child. A second child should be created to read and display data from the file. Make use of any appropriate Inter Process Communication technique to ensure that the second child and the parent do not access the file simultaneously (Mutual exclusion).

View 5 Replies View Related

Programming :: CreateProcess() In C \ Specify The Location Of The File As An Argument?

Aug 31, 2010

am coding a chat program in C (win32), where I need both the client and the server to communicate, without waiting for a reply from the other side, like the way we chat in any messenger. Is there any way of accomplishing it? I tried out CreateProcess() function, but am not clear how to specify the location of the file as an argument.If there are better techniques than CreateProcess(), then

View 13 Replies View Related

Programming :: Shell: Give A Range Argument To 'for'

Feb 20, 2010

Feel free to just link to another thread where this is (pre)solved; I can't search the forum for the word "for," because it's too short (or maybe the search engine dislikes prepositions).

Is there a way to give the 'for' command a range? Here's what I mean:

Code:
#for i in (1-5); do echo $i; done
Certainly, meat space user; I understand exactly what you're thinking.
1
2
3
4
5
True, I realize I could use

Code:
COUNT=1 ; while [ $COUNT -lt 6 ]...

...but if I can avoid the extra preparatory step I'd prefer to do so.

View 2 Replies View Related

Programming :: Pass Complicated Commands As Argument To Another Script?

Apr 21, 2010

I am attempting to script some tasks I have to do, but I have no control over one of the scripts I have to use... and they output all kinds of useless things on the screen. My goal is simple: Capture all output from their scripts, and create a progress line that only shows the most recent output from their stuff. So, here was my first solution; a file I called "spin":

Code:
#!/bin/bash
spinX(){
PROC=$1
STRT='date "+%s"'
while [ -d /proc/$PROC ];do
last3=" 'getLine $2' "

To use it, you pass it a process ID and a file that contains the output from that process. As the process continues, a kurby dances on the screen (To let you know that the process has not hanged), and the tail of the output is shown (To let you know what it is doing). When the process ends, the kurby stops dancing and the time it took is displayed.

And here is the file I call "noise":
Code:
#!/bin/bash
while [ i -lt 100 ];do
i=1
echo "Look at me count!$"
sleep 1
let "i=$i+1"
done

This does nothing but create random output, for testing. It counts from 1 to 99 on the screen. To run my test, I do the following:
Code:
(noise) &>tmp.txt & spin $! tmp.txt

It works relatively well, but it is messy. I don't like creating a temp file, and I don't like the messy syntax for calling my program. I decided that I would rather move everything into the spin program, to make using it less messy:
Code:
#Spin Psuedo code
#$1 = command I am about to run
(exec $1) &>tmp.txt & spinX $! tmp.txt

By executing the process inside of the spin code, I can get rid of the tmp file later on without changing a lot of scripts (Or move it, or whatever). I can also call it by passing the command to the script, which I find more elegant.

So here is what I would like to know:
1) If possible, I would love to get rid of the tmp file all together, and store the most recent line of output from script 1 into a variable that script 2 can print out instead... is it possible?
2) How can I run a random command that is passed as an argument? Basic ones work fine, but anything with a pipe fails me.

Example of a script:
Code:
#!/bin/bash
#myEcho.sh
echo;echo "Recieved command: ";echo $1;echo;
echo "Attempting to run command: ";echo
exec $1

Example code for passing commands to script:
> myEcho.sh "ls -al" #works
> myEcho.sh 'ls -al' #works
> myEcho.sh "ls -al|grep *.sh" #fail
# Output:
#ls: invalid option -- |
#Try 'ls --help' for more information.
> myEcho.sh "ls -al|grep "*.sh"" #fail
# Output:
#ls: invalid option -- |
#Try ls --help' for more information.
> myEcho.sh 'ls -al|grep *.sh' #fail
# Output:
#ls: invalid option -- |
#Try 'ls --help' for more information.

View 8 Replies View Related

Programming :: Ssh Remote Command Preserve Quoted Argument?

Sep 17, 2009

I have a python script on one server (serv_one) and I am trying to execute it remotely from another (serv_two). The python script takes an argument with spaces. If I execute it locally:

Code:

foo@serv_one> script.py --o "arg one"
"arg one" is preserved, of course. ( argv = [ '--o', 'arg one' ] )

However, when I execute it remotely:

Code:

foo@serv_two> ssh ... foo@serv_one script.py --o "arg one"

the double quotes around "arg one" are dismissed ( argv = [ '--o', 'arg', 'one' ]. I've tried many combinations of single quotes/double quotes/backslashes, etc, to no avail. One hack solution I came up with, since I have the flexibility, was to replace all spaces in the quoted argument with a character that would be invalid in the argument (before the ssh call), and replace those with spaces in script.py. I would probably like to avoid this solution if at all possible.

View 7 Replies View Related

Programming :: C++ Program Calling A Fortran Subroutine With A Function In The Argument?

Mar 9, 2011

I have a new problem; i want to call a subroutine's fortran which have a function in the argument and the compilation ran properly, but when i execute the program this shows me an "Segmentation fault". This is my c++ program:

Code: //Main.cpp
#include <stdio.h>
#include <iostream>

[code]....

View 2 Replies View Related

Programming :: Handle Non Argument Error While Adding Two Alphabets Using 'expr'

Feb 19, 2011

how to handle non argument error while adding two alphabets using 'expr' (not bc).

View 1 Replies View Related

Programming :: Shell Scripting - Value Disappears Depending On Argument Order

Mar 21, 2011

Examples:
Code:
$ ./test.sh -a -c 2
operator is -gt
remcount is
^ value missing!

Code:
$ ./test.sh -b -c 2
operator is -lt
remcount is
^ value missing!

Yet when "-c" is the first argument, its value is present:
Code:
$ ./test.sh -c 2 -b
operator is -lt
remcount is 2
What could I do to ensure the value of "-c" is picked up regardless of the argument order?

View 5 Replies View Related

Programming :: Make A Template Char Or Wchar_t Default Function Argument?

Oct 30, 2009

I have a template similar to the following.

Code:

template <charT>
virtual void do_get_date(charT* = "str")
{ ... }

As you can see we have a problem. If we use a wchar_t instead the string wont be formatted right we need to prefix L in front. If we use char16_t we need to prefix a u in front. Is there a was to make the generic without resorting the the std::string class?

View 2 Replies View Related

Programming :: Bash Shell Read User Argument From Command Line And Test It

Aug 29, 2010

Trying to create a small script that will read user's input, test if user entered some input and if not display some message or display a text using user's input.

The script is the following but i get an error saying "[: 6: =: argument expected"

View 12 Replies View Related

Programming :: Vfprintf In 64-bit Environment - Warning: Passing Argument 3 Of Vfprintf From Incompatible Pointer Type

Apr 14, 2010

I want to use vfprintf with the char * on 64-bit. Here is the sample code:

[Code]...

In this code, I am getting warning: passing argument 3 of vfprintf from incompatible pointer type I have done sizeof(va_list) on 64-bit, and its 24 bytes. I don't know how am I suppose to use the va_list this way.

View 1 Replies View Related

Programming :: Warning: Pointer Targets In Passing Argument 1 Of "STRING_stricmp" Differ In Signedness

Jul 13, 2011

i have this warning "differ in signedness".

[Code]...

so i was getting this error. im thinking it may be because of somewhere i declared unsigned and signed so this signedness warning occurring.

Code:

switcase.c: In function ImplementDebugCmd: switcase.c:385: warning: pointer targets in passing argument 1 of STRING_stricmp differ in signedness

View 1 Replies View Related

Programming :: Bash Array Add Function Example Using Indirect Array Reference As Function Argument?

Jun 20, 2010

I looked on the net for such function or example and didin't find anything, thus after having made one i guess it would be legitimate to drop it to see what others thinks of it.

#!/bin/bash
addelementtoarray()
{
local arrayname=$1

[code]....

View 10 Replies View Related

Debian Configuration :: Bad Argument '#' In Iptables

Jul 11, 2011

I follow this instructions but after iptables-restore < /etc/iptables.test.rules I see this error # iptables-restore < /etc/iptables.test.rules Bad argument `#' Error occurred at line: 3 Try `iptables-restore -h' or 'iptables-restore --help' for more information. The line 3 is the same as the link - # Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0

View 3 Replies View Related

General :: Setting Tcp Ip Argument While Booting Up?

Nov 23, 2010

how to set the tcp ip parameter while linux boots up in my board.

Currently i am giving it like : tcp ip=:::::eth0:dhcp

If i have my own static ip and its corresponding mac-id can i change it for my board when i boot up.

View 1 Replies View Related

Networking :: No Match For Argument - Ypserv ?

Mar 18, 2010

Heres what i have done:

Am i missing anything ? What is going wrong here?

View 1 Replies View Related

Red Hat :: Error Inserting MD5 - Invalid Argument

Mar 24, 2011

I am running Red Hat with 2.6.18-194.8.1.el5PAE kernel version. I am trying to run encryptfs to encrypt a partition on my hard drive. One of the kernel modules necessary is the md5.ko. I noticed it wasn't loaded in when doing an lsmod. I tried running modprobe md5 and it fails to load:

[root@ ~]# /sbin/modprobe -v md5
insmod /lib/modules/2.6.18-194.8.1.el5PAE/kernel/crypto/md5.ko
FATAL: Error inserting md5 (/lib/modules/2.6.18-194.8.1.el5PAE/kernel/crypto/md5.ko): Invalid argument

I ran dmesg and grepped for md5, but I didn't see anything in there.

View 1 Replies View Related

Fedora :: Argument Against Auto-mounting Of Other Partitions?

Apr 14, 2011

I boot several Redhat based distributions, Fedora 15, Fedora 14, CentOS, Scientific Linux, Redhat and occasionally something non-Redhat based like Ubuntu and Debian. Out of habit and preference I frequently set up partitions to be auto mounted at boot through fstab. Somewhere in time something went seriously wrong with the CentOS install. There are a ton of permission denied errors while booting CentOS (text style boot) mostly regarding shared libraries. The system will boot to the desktop and everything looks OK but some things don't work. I can't update the system because I have no network connection. I obviously can't get to the Internet or get e-mail. I can open a VT but can't log in as regular user or root.

Permission denied in both instances. I didn't make any drastic changes to the CentOS system, just minor tweaks. The culprit in my opinion is a combination of the fact that one of the other Linux systems did an SELinux relabel while booting and the CentOS partition was already mounted. Since the CentOS partition was mounted it too was relabeled. I can't prove this. If there's a way to prove it then I just don't have the skills or knowledge to do so. It's basically a theory based on what I know I've done with the several installed distributions. This is not a rant nor is it a request for help. Just a comment. An assumption, hopefully a correct assumption. The CentOS install was working flawlessly until something happened and I think that something was the SELinux relabel.

View 6 Replies View Related

General :: Argument To Cp In Backticks Doesn't Work?

Nov 9, 2010

I tried using a command likecp `ls ~/temp/*.xyz | head -1` ./But that does not work. If I echo the value of command inside back ticks and put it manually in cp command it works.

View 2 Replies View Related

General :: Find Argument List Too Long?

May 12, 2011

I want to search in many many files for a string.

I used find /archive/* -print0 | xargs -0 grep 'robert' -sl

Is there a simple method to do it ?

View 2 Replies View Related

Ubuntu :: Echo Command To Output First Argument

Nov 5, 2010

In a script, when I enter "echo $1" the first argument is outputted. When I enter:
a=1
echo "$$a"

The output is just "$1", not the first argument. If I enter:
a=1
b=$$a
echo $b

The output is still "$1" and not the first argument. How can I get echo to output the first argument without use "$1" directly?

View 4 Replies View Related

Ubuntu :: TTY Fonts - KDFONTOP: Invalid Argument ?

Jan 15, 2011

I was trying to change the console fonts. I remember that I did successfully change the console fonts back when I was using Jaunty with this:

Code:

View 8 Replies View Related

Ubuntu :: Error Failed: Invalid Argument

Mar 5, 2011

i downloaded baldurs gate II shadows of amn iso's, because i lost one of the CD's to the box, but anyways, I went to mount the third .ISO for installation, and BAM! my computer froze, so i waited five minutes, came back, and still frozen. shut it down for 20 minutes, pulled it back up, and it's got this error as follows; "Mount: mounting /dev/disk/by-uuid/65b0a6a-a366-435a-a086-58428cfe2bd1 on /root Failed: invalid argument

[code]...

View 6 Replies View Related

Ubuntu :: Calling Script With Argument From C Program?

Feb 8, 2010

I am trying to take argument from command line ic a Cprogram an give that argument as an argument to a script file which is called in that C program.Is it possible for example:

my C program is:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

[code]....

I want to fill that blank with thevalue of argv[1] such that it will act as an argument for temp1.sh.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved