Free coupon for initial registration

Execute system command in program and get the result

Contents [hide]

Output

Current time like this

Mon Dec  9 07:08:08 JST 2019

Code examples


JavaScript

1
2
3
const execSync = require('child_process').execSync;
let result = execSync('date').toString();
console.log(result);

PHP

1
2
3
<?php
exec('date', $rtn);
print($rtn[0]."\n");

Perl

1
2
my $result = `date`;
print($result."\n");

Python

1
2
3
import subprocess
result = subprocess.check_output(["date"], shell=True).decode("UTF-8")
print(result)

Ruby

1
2
result = `date`
print(result)

Shell

1
2
3
#!/bin/sh
RESULT=`date`;
echo $RESULT;
Free coupon for initial registration