Hi,
i have a file.txt with data
Bangalore
Chennai
Hyd
filename of the script is: new.sh
i am executing the file in the cmd line as "sh new.sh Bangalore"
o/p is pass
if i give "sh new.sh delhi"
o/p is test:argument expected ( it does not say fail).
Kindly help, Thank you.
Last edited by jim mcnamara; 02-20-2012 at 08:41 AM..
Reason: code tags please
I'm trying to pass a filename, or all the files in the current directory to the ls command with a script. Unsuccessful so far, here are a few of my attempts:
#!/bin/ksh
read fname
#if (( $# > 0 )); then
$fname | ls -l
#fi
this produces a long listing of all the files in my current... (4 Replies)
I want to have an alias for the command
fold -78 filename | lp
How do I set my alias so that the argument passed is filename ??
alias lp='fold -78 | lp'
then
lp filename
wont work cuase this is
fold -78 | lp filename (1 Reply)
I've written a script (bgrep) for a more advanced grep command (& attached a cut down version below). I'm trying allow all grep options to be used, or in any combination.
The script works fine if I type say
bgrep -i -files product
it will return a non-case sensitive list of matches for... (3 Replies)
Hi,
I have a script which adds the user credentials to an ldap server. Im passing the variables as below..
/path/my_script $uname $pwd $environ ${deposit}
If i enter some special characters like ';' in $pwd, script returns an error which is set to display if the user enters... (5 Replies)
Hi
I have a script to which I pass multiple arguments, for example lets say the script name is "abc". I run the script like
./abc def /file <directory location>
In the above "def" is the first argument and "/file" is the second argument. I expect <directory location> that is passed after... (4 Replies)
I need to pass arguments to a shell script.My batch is calling some java program.
#################
x=$1
y=$2
java -classpath program
###################
if first parameter and second parameter is null then
java -classpath program
if first parameter is not null and second parameter is... (3 Replies)
Is there any way I could pass arguments to shellcode. My goal is to store a program in a image file, and have another program read and run the code with arguments in memory.
Currently I can store a program in a image file, then read it back to the hard-drive run it normally then delete it when... (5 Replies)
I have an for loop that reads the following file
cat param.cfg
val1:env1:opt1
val2:env2:opt2
val3:env3:opt3
val4:env4:opt4
.
.
The for loop extracts the each line of the file so that at any one point, the value of i is
val1:env1:opt1 etc...
I would like to extract each... (19 Replies)
hi All,
i am trying to pass arguments that contain space , value will be stored in variables to be used further in script , i went thru previous posting , still its not clear to how to implement for my case.
passing 3 args
test.sh it is 'fun to work in unix'
inside shell
... (3 Replies)
Hi,
I am using awk here.
Inside an awk script, I have a variable which contains a very long XML data in string format (500kb).
I want to pass this data (as argument) to curl command using system function.
But getting Too many arguments error due to length of string data(payloadBlock).
I... (4 Replies)
Discussion started by: cool.aquarian
4 Replies
LEARN ABOUT PHP
finfo_open
FINFO_OPEN(3) 1 FINFO_OPEN(3)finfo_open - Create a new fileinfo resource
Procedural style
SYNOPSIS
resource finfo_open NULL ([int $options = FILEINFO_NONE], [string $magic_file])
DESCRIPTION
Object oriented style (constructor): finfo::__construct NULL ([int $options = FILEINFO_NONE], [string $magic_file])
This function opens a magic database and returns its resource.
PARAMETERS
o $options
- One or disjunction of more Fileinfo constants.
o $magic_file
- Name of a magic database file, usually something like /path/to/magic.mime. If not specified, the MAGIC environment variable is
used. If the environment variable isn't set, then PHP's bundled magic database will be used. Passing NULL or an empty string will
be equivalent to the default value.
RETURN VALUES
(Procedural style only) Returns a magic database resource on success or FALSE on failure.
NOTES
Warning
The expected magic database format changed in PHP 5.3.11 and 5.4.1. Due to this, the internal magic database was upgraded. This
mostly effects code where an external magic database is used: reading an older magic file will now fail. Also, some textual repre-
sentations of the mime types has changed, for instance for PHP would be "PHP script, ASCII text" instead of "PHP script text"
returned.
Note
Generally, using the bundled magic database (by leaving $magic_file and the MAGIC environment variables unset) is the best course
of action unless you specifically need a custom magic database.
EXAMPLES
Example #1
Object oriented style
<?php
$finfo = new finfo(FILEINFO_MIME, "/usr/share/misc/magic"); // return mime type ala mimetype extension
/* get mime-type for a specific file */
$filename = "/usr/local/something.txt";
echo $finfo->file($filename);
?>
Example #2
Procedural style
<?php
$finfo = finfo_open(FILEINFO_MIME, "/usr/share/misc/magic"); // return mime type ala mimetype extension
if (!$finfo) {
echo "Opening fileinfo database failed";
exit();
}
/* get mime-type for a specific file */
$filename = "/usr/local/something.txt";
echo finfo_file($finfo, $filename);
/* close connection */
finfo_close($finfo);
?>
The above example will output:
text/plain; charset=us-ascii
SEE ALSO finfo_close(3).
PHP Documentation Group FINFO_OPEN(3)