Sponsored Content
Top Forums Programming Problem on acquiring arguments with asterisk '*' (C language) Post 302550032 by shamrock on Wednesday 24th of August 2011 11:59:54 AM
Old 08-24-2011
Quote:
Originally Posted by D4vid
Hi everybody, I wrote a simple C programm on Unix (HP-UX). Initially, it has to acquire some arguments by command line and
print them on video. I use:

printf("%s\n",argv[i]);

where 'i' represents the numner of arguments in a 'for' cycle.

Problems begin when I pass a parameter containing '*' character, like this:

ab*1234*

the programm return me this sentence: "No match."
That just means that there are no files in the current directory that match that criteria...otherwise the shell would have expanded the * before passing it to your program...and if you need to pass the arguments as is then you need to put them in quotes to prevent the shell from expanding them. The error mesage is certainly weird...thogh i think it is one that you put in yourself...but then again it is hard to say without looking at your program.
Quote:
Originally Posted by D4vid
After acquiring, these arguments would be passed to a system call so i need to load these as i write them (with asterisks).

Someone can help me ?

thanks a lot.
Alex.
What system call are we talking about...just to make sure im not confusing it with the system lib call that issues a shell command.
 

3 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

problem in replacing asterisk in sed

Hi all, Sed is the one which always trobules me :( here is my input : *** it industry need to be evolved *** in the world and hope so *** to be dream the output i am expecting is : *** it industry need to be evolved *** in the world and hope so *** to be dream ... (4 Replies)
Discussion started by: panyam
4 Replies

2. Programming

How to pass the command line arguments to the shell script in c language?

hi, I am new in the shell script, and c programming with linux. I am looking to pass the arguments in c program that should be executed by the shell script. e.g. #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv) { int i; for (i=1;i<argc; i++) { ... (2 Replies)
Discussion started by: sharlin
2 Replies

3. Proxy Server

Building up apache httpd on AIX - acquiring RPMs etc.

pardon the ed URL refs but I'm not allowed to post URLs yet. and the misspelling in the original thread title, which I can't edit even in 'advanced' greetings all, posting this here rather than in Web Development since I suspect this is rather AIX-specific and will need some arcane knowledge,... (2 Replies)
Discussion started by: maraixadm
2 Replies
ShellQuote(3pm) 					User Contributed Perl Documentation					   ShellQuote(3pm)

NAME
String::ShellQuote - quote strings for passing through the shell SYNOPSIS
$string = shell_quote @list; $string = shell_quote_best_effort @list; $string = shell_comment_quote $string; DESCRIPTION
This module contains some functions which are useful for quoting strings which are going to pass through the shell or a shell-like object. shell_quote [string]... shell_quote quotes strings so they can be passed through the shell. Each string is quoted so that the shell will pass it along as a single argument and without further interpretation. If no strings are given an empty string is returned. If any string can't be safely quoted shell_quote will croak. shell_quote_best_effort [string]... This is like shell_quote, excpet if the string can't be safely quoted it does the best it can and returns the result, instead of dying. shell_comment_quote [string] shell_comment_quote quotes the string so that it can safely be included in a shell-style comment (the current algorithm is that a sharp character is placed after any newlines in the string). This routine might be changed to accept multiple string arguments in the future. I haven't done this yet because I'm not sure if the strings should be joined with blanks ($") or nothing ($,). Cast your vote today! Be sure to justify your answer. EXAMPLES
$cmd = 'fuser 2>/dev/null ' . shell_quote @files; @pids = split ' ', `$cmd`; print CFG "# Configured by: ", shell_comment_quote($ENV{LOGNAME}), " "; BUGS
Only Bourne shell quoting is supported. I'd like to add other shells (particularly cmd.exe), but I'm not familiar with them. It would be a big help if somebody supplied the details. AUTHOR
Roderick Schertler <roderick@argon.org> SEE ALSO
perl(1). perl v5.8.4 2005-05-03 ShellQuote(3pm)
All times are GMT -4. The time now is 01:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy