Hi
I was able to pass parameters to a shell script from the command line but now, I am trying to make the shell script to get those parameters/values from a file.
Please give me ideas how to do this or if you have an example or website that shows how to do this.
I tried searches but it... (2 Replies)
Can anyone help me how to write a shell script which accepts input parameter. My requirement is as follows:
I need to run a shell script with a input parameter, and inside the script i will create a file with this input parameter name.
Please help me out to create such a shell script.
... (1 Reply)
Hi
I need to pass a date argument with my shell script. Can any one send me code for the same.
eg For 15th Aug 2006. Iwant to pass parameter like this
./startenv.sh 08/15/2006.
Everyday date argument must change. Will the below code work ?
./startenv.sh date '+%m/%d/%y'
THanks... (1 Reply)
I have a script file as below named test1.sh
sed -e 's/xxxkeys/$1/g' template1.asp > template1.txt
sed -e 's/xxxkeys/$2/g' template2.asp > template2.txt
sed -e 's/xxxkeys/$3/g' template3.asp > template3.txt
sed -e 's/xxxkeys/$4/g' template4.asp > template4.txt
I want to replace $1 with a,... (1 Reply)
Hi,
I am new to unix and using linux 7.2. I would like to create a script that would make it easyer for me to run my java programms. At the moment I have to type java myJavaprogram
I am trying to write a script that will allow me to type something like this "myscript myJavaprogram" or maybe... (4 Replies)
I am trying to get the string containing date - in a specfic format actually, although I think that part is inconsequencial - 1110226^1110226^1110226^1110226^1110226 - through echo or printf or in some other way - created within a cront job and passed as a parameter to a perl script.
Now, I know... (3 Replies)
Hello Everyone,
I have been trying to complete a shell script where, I need to increment the date depending on the file (depending on the date) availability on the remote server.
i.e.
Basically, I will be passing a counter (like parameter 1 or 2 or 3 or 4).
First I will check for the... (1 Reply)
Hi
I have two shell script, the second script takes as a parameter the output variable of the first script, please how to retrieve the variable from the first script to pass as a parameter to the second script?
Script1.sh
i=0
i=$(($i + 1))
Script2.sh
echo $1
Thank you (0 Replies)
Discussion started by: chercheur111
0 Replies
9. Post Here to Contact Site Administrators and Moderators
Variable I have in my shell script
diff=$1$2.diff
id=$2
new=new_$diff
echo "My id is $1"
echo "I want to sync for user account $id"
##awk command I am using is as below
cat $diff | awk -F'~' ''$2 == "$id"' {print $0}' > $new
I could see value of $id is not passing to the awk... (0 Replies)
I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist.
diff=$1$2.diff
id=$2 new=new_$diff
echo "My id is $1"
echo "I want to sync for user account $id"
##awk command I am using is as below
cat $diff |... (1 Reply)
Discussion started by: Sarita Behera
1 Replies
LEARN ABOUT PHP
datetime.add
DATETIME.ADD(3) 1 DATETIME.ADD(3)DateTime::add - Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object
Object oriented style
SYNOPSIS
public DateTime DateTime::add (DateInterval $interval)
DESCRIPTION
Procedural style
DateTime date_add (DateTime $object, DateInterval $interval)
Adds the specified DateInterval object to the specified DateTime object.
PARAMETERS
o $object
-Procedural style only: A DateTime object returned by date_create(3). The function modifies this object.
o $interval
- A DateInterval object
RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure.
EXAMPLES
Example #1
DateTime.add(3) example
Object oriented style
<?php
$date = new DateTime('2000-01-01');
$date->add(new DateInterval('P10D'));
echo $date->format('Y-m-d') . "
";
?>
Procedural style
<?php
$date = date_create('2000-01-01');
date_add($date, date_interval_create_from_date_string('10 days'));
echo date_format($date, 'Y-m-d');
?>
The above examples will output:
2000-01-11
Example #2
Further DateTime.add(3) examples
<?php
$date = new DateTime('2000-01-01');
$date->add(new DateInterval('PT10H30S'));
echo $date->format('Y-m-d H:i:s') . "
";
$date = new DateTime('2000-01-01');
$date->add(new DateInterval('P7Y5M4DT4H3M2S'));
echo $date->format('Y-m-d H:i:s') . "
";
?>
The above example will output:
2000-01-01 10:00:30
2007-06-05 04:03:02
Example #3
Beware when adding months
<?php
$date = new DateTime('2000-12-31');
$interval = new DateInterval('P1M');
$date->add($interval);
echo $date->format('Y-m-d') . "
";
$date->add($interval);
echo $date->format('Y-m-d') . "
";
?>
The above example will output:
2001-01-31
2001-03-03
NOTES DateTime.modify(3) is an alternative when using PHP 5.2.
SEE ALSO DateTime.sub(3), DateTime.diff(3), DateTime.modify(3).
PHP Documentation Group DATETIME.ADD(3)