I would like to prompt for input and then use it as a variable in a script.
Something like this.
#!/bin/ksh
echo "What is your name?: \c"
read response
echo "Your name is $reply" >file.txt
done
exit 0
What am I missing?
Thanks, (7 Replies)
I have a shell script I want to run that will set environment variables based on the value of an input variable submitted when the shell script is called. For example:
$ mgenv.sh prod
This would set environment variables for prod
$ mgenv.sh test
This would set environment variables... (1 Reply)
Hi
I am trying to edit a csv file. Bacically I need to input a search variable and the value that must be changed in one of the fields corresponding to that searched variable.
My csv file looks like so:
1,1A,5
1,1B,2
1,1C,3
2,2A,7
2,2B,4
2,2C,0
3,3A,1
3,3B,6
3,3C,4
I want to... (4 Replies)
Hi, I'm trying to make a script which you type the year, select the month and day and then create the date in the format 2010-12-7.
#!/bin/bash
dia () {
echo " Seleccione el dia:"
select file in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Salir
do... (6 Replies)
Hi guys,
Does awk have a built-in variable which I can use to display the input file it's currently reading?
I'm currently concatenating multiple files using awk and later on do some parsing. But for now, I want to add an extra column in the main output data file - basically putting in the... (3 Replies)
Here is the requirement, When I run the "run file KSH (sql)", it should substitute
'${pCW_Bgn_DT}' with 201120
and
'${pCW_End_DT}' with 201124
Input File
----------
$ cat prevwk.dat
201124 20110711
run file KSH (sql)
------------------
In this file, I want to use the variables... (1 Reply)
Hi Gurus,
I need a suggestion, please help. I have a input file as below :
abc.txt :
*
xxxx: 00000
xxxxx: 00000
xxxx: RANDOM
xxx: RANDOM
**************************xxxxxxx***
* abc
******************************
abc:
abc: ... (3 Replies)
Hi everyone,
Can anyone tell me how to take contents of a variable as a pattern for awk command. Am doing as below, but doesnt get any output:
$c = "Tue Dec";
$log = ` awk '/ \$c /' in.txt`;
print $log; (7 Replies)
Hi,
I would like to compare 2 files using awk, which I can do by using:
awk 'NR==FNR{a;next} (NR > 32 && $2 in a) {print $0}' File1 and File2.
If the name of the File1 is in another file (for example, column 4 in File 3) then how can I pass this column 4 to the awk command.
Thanks in... (1 Reply)
HI,
MY question is a very simple one:
if i want to call an awk script with the input file name and also pass a variable value , then how to do it.
#>awk -f my_script.awk -v variable=value my_inputfile.txt
I can't do it like this.
throws error:
awk: my_script.awk:18:... (0 Replies)
Discussion started by: Onkar Banerjee
0 Replies
LEARN ABOUT PHP
ip2long
IP2LONG(3) 1 IP2LONG(3)ip2long - Converts a string containing an (IPv4) Internet Protocol dotted address into a proper addressSYNOPSIS
int ip2long (string $ip_address)
DESCRIPTION
The function ip2long(3) generates an IPv4 Internet network address from its Internet standard format (dotted string) representation.
ip2long(3) will also work with non-complete IP addresses. Read http://publibn.boul-
der.ibm.com/doc_link/en_US/a_doc_lib/libs/commtrf2/inet_addr.htm for more info.
PARAMETERS
o $ip_address
- A standard format address.
RETURN VALUES
Returns the IPv4 address or FALSE if $ip_address is invalid.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
|5.2.10 | |
| | |
| | Prior to this version, ip2long(3) would some- |
| | times return a valid number even if passed an |
| | value which was not an (IPv4) Internet Protocol |
| | dotted address. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
ip2long(3) Example
<?php
$ip = gethostbyname('www.example.com');
$out = "The following URLs are equivalent:<br />
";
$out .= 'http://www.example.com/, http://' . $ip . '/, and http://' . sprintf("%u", ip2long($ip)) . "/<br />
";
echo $out;
?>
Example #2
Displaying an IP address
This second example shows how to print a converted address with the printf(3) function in both PHP 4 and PHP 5:
<?php
$ip = gethostbyname('www.example.com');
$long = ip2long($ip);
if ($long == -1 || $long === FALSE) {
echo 'Invalid IP, please try again';
} else {
echo $ip . "
"; // 192.0.34.166
echo $long . "
"; // -1073732954
printf("%u
", ip2long($ip)); // 3221234342
}
?>
NOTES
Note
Because PHP's integer type is signed, and many IP addresses will result in negative integers on 32-bit architectures, you need to
use the "%u" formatter of sprintf(3) or printf(3) to get the string representation of the unsigned IP address.
Note
ip2long(3) will return FALSE for the IP 255.255.255.255 in PHP 5 <= 5.0.2. It was fixed in PHP 5.0.3 where it returns -1 (same as
PHP 4).
SEE ALSO long2ip(3), sprintf(3).
PHP Documentation Group IP2LONG(3)