03-18-2009
Hi. When you write a script/program in vi . Do you include the $ Eg. . $ echo "Today's date is `date`" or . echo "Today's date is `date`" . Make your script executable. . $chmod +x script I included that. . I keep getting a permission denied... why? Thanks!
10 More Discussions You Might Find Interesting
1. Programming
hi
I want to call a shell script in C program
the script is : ssh -t user@remote sh /<remote>home/user/<file_name>.sh
and other several commands
C program : Call this script and the retrive the task that is been done in <file_name>.sh file
can any one tell me how... (5 Replies)
Discussion started by: mridula
5 Replies
2. Shell Programming and Scripting
I want to add lines in my script dynamically.
My script:
...
echo addscript
end addscript
...
Lines to add: (can be put in a file and can be added)
cp /opt/script1.sh opt/script1_org.sh
sed 's/testusr/'${FUNCTID}'/g' /opt/script1.sh > ./tmpfile
mv ./tmpfile /opt/script1.sh... (1 Reply)
Discussion started by: chiru_h
1 Replies
3. Shell Programming and Scripting
I'm new in this.
In C/C++, you define variables in one header file & then simply include it in any files where those variables are referenced.
I tried to include a header named DefineVars- which initializes all the globals- but when I add the line "DefineGlobals" at the begining of another... (2 Replies)
Discussion started by: bluemoon1
2 Replies
4. Shell Programming and Scripting
Please tell me that how can we include Spreadsheet::ParseExcel module in shell script (1 Reply)
Discussion started by: akash
1 Replies
5. UNIX for Dummies Questions & Answers
Hi Gurus,
Is it possible to include perl script with in the unix shell script?
What would be the general syntax?
In the above case, is it required to write the below first two lines of codes?
#!usr/bin/sh -x
#!usr/bin/perl -w
Thanks in advance / Mysore Ganapati. (1 Reply)
Discussion started by: ganapati
1 Replies
6. Shell Programming and Scripting
Hello,
I have a script and a second file that contains all parameters needed for the script.
How can I include this file in the script ?
I tried source but I have a "no such file or directory" error.
:) (1 Reply)
Discussion started by: pppswing
1 Replies
7. UNIX for Dummies Questions & Answers
Hi,
i want to write a script that executes a program (exec?) .
this program then requires a filename as input.
how do i give it this input in the script so the program will be complete run and close by the script.
e.g.
exec prog.exe
program then asks for filename
"enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies
8. Shell Programming and Scripting
# dbc "delete from alert;"
DELETE 10
#
However, the script created below generates an error that command does not exits. Can any one please exist.
script.sh:
#!/bin/sh
dbc "delete from alert;" >>$TASKLOGFILE
./script.sh: line 38: dbc: command not found
can any one please... (2 Replies)
Discussion started by: sureshcisco
2 Replies
9. UNIX for Dummies Questions & Answers
Hi guys i have written a script which takes the options given to him and execute itself accordingly.
for example
if a script name is doctortux then executing doctortux without option should made doctortux to be executed in automatic mode i.e. doctortux -a
or if a doctortux is needed to run in... (4 Replies)
Discussion started by: pinga123
4 Replies
10. Shell Programming and Scripting
Hi,
I have a script I am developing (actually more than 1 just now).
1st part - executes SQL in a 2nd script.
2nd part - reformats the output of the sql into a csv
Problem:
How am I able to run the SQL from the first script? I assume there is a sql command? I generally use isql when... (6 Replies)
Discussion started by: mcclunyboy
6 Replies
LEARN ABOUT PHP
datetime.__construct
DATETIME.__CONSTRUCT(3) 1 DATETIME.__CONSTRUCT(3)
DateTime::__construct - Returns new DateTime object
Object oriented style
SYNOPSIS
public DateTime::__construct NULL ([string $time = "now"], [DateTimeZone $timezone])
DESCRIPTION
Procedural style
DateTime date_create NULL ([string $time = "now"], [DateTimeZone $timezone])
Returns new DateTime object.
PARAMETERS
o $time
-A date/time string. Valid formats are explained in Date and Time Formats. Enter NULL here to obtain the current time when using
the $timezone parameter.
o $timezone
- A DateTimeZone object representing the timezone of $time. If $timezone is omitted, the current timezone will be used.
Note
The $timezone parameter and the current timezone are ignored when the $time parameter either is a UNIX timestamp (e.g.
@946684800) or specifies a timezone (e.g. 2010-01-28T15:00:00+02:00).
RETURN VALUES
Returns a new DateTime instance. Procedural style returns FALSE on failure.
ERRORS
/EXCEPTIONS
Emits Exception in case of an error.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.0 | |
| | |
| | If $time contains an invalid date/time format, |
| | then an exception is now thrown. Previously an |
| | error was emitted. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
DateTime.__construct(3) example
Object oriented style
<?php
try {
$date = new DateTime('2000-01-01');
} catch (Exception $e) {
echo $e->getMessage();
exit(1);
}
echo $date->format('Y-m-d');
?>
Procedural style
<?php
$date = date_create('2000-01-01');
if (!$date) {
$e = date_get_last_errors();
foreach ($e['errors'] as $error) {
echo "$error
";
}
exit(1);
}
echo date_format($date, 'Y-m-d');
?>
The above examples will output:
2000-01-01
Example #2
Intricacies of DateTime.__construct(3)
<?php
// Specified date/time in your computer's time zone.
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:sP') . "
";
// Specified date/time in the specified time zone.
$date = new DateTime('2000-01-01', new DateTimeZone('Pacific/Nauru'));
echo $date->format('Y-m-d H:i:sP') . "
";
// Current date/time in your computer's time zone.
$date = new DateTime();
echo $date->format('Y-m-d H:i:sP') . "
";
// Current date/time in the specified time zone.
$date = new DateTime(null, new DateTimeZone('Pacific/Nauru'));
echo $date->format('Y-m-d H:i:sP') . "
";
// Using a UNIX timestamp. Notice the result is in the UTC time zone.
$date = new DateTime('@946684800');
echo $date->format('Y-m-d H:i:sP') . "
";
// Non-existent values roll over.
$date = new DateTime('2000-02-30');
echo $date->format('Y-m-d H:i:sP') . "
";
?>
The above example will output something similar to:
2000-01-01 00:00:00-05:00
2000-01-01 00:00:00+12:00
2010-04-24 10:24:16-04:00
2010-04-25 02:24:16+12:00
2000-01-01 00:00:00+00:00
2000-03-01 00:00:00-05:00
SEE ALSO
DateTime.createFromFormat(3), DateTimeZone.__construct(3), Date and Time Formats, date.timezone ini setting, date_default_time-
zone_set(3), DateTime.getLastErrors(3), checkdate(3).
PHP Documentation Group DATETIME.__CONSTRUCT(3)