Trouble with date

Im trying to incorporate the date into a directory path

I want to name a folder using the bash command "date +%y%m%d" and then
call that path later on in the script as in:

# This works great
  today = `date +%y%m%d`
  directory = "mkdir -p /Users/me/github/splat/`date +%y%m%d`"
  exec directory

#This part doesnt work

command = "git clone --mirror https://github.com/org/#{repo_name}.git
/Users/me/github/splat/`date +%y%m%d`/#{repo_name}/"
  exec command

As I understand it when the backticks are used it opens a sub shell, how
can I get that directory name?

···

--
Posted via http://www.ruby-forum.com/.

Seems to be going a long way 'round something pretty simple.

today = Time.now.strftime("%Y%m%d")
save_path = "/Users/me/github/splat/#{today}"
system("mkdir -p #{save_path}")

# ... later

system("git clone --mirror org (org) · GitHub
#{save_path}/#{repo_name}")

Adjust scope on variables as necessary...

···

On Sat, Dec 1, 2012 at 7:19 PM, Pierre-Andre M. <lists@ruby-forum.com> wrote:

Im trying to incorporate the date into a directory path

I want to name a folder using the bash command "date +%y%m%d" and then
call that path later on in the script as in:

# This works great
  today = `date +%y%m%d`
  directory = "mkdir -p /Users/me/github/splat/`date +%y%m%d`"
  exec directory

#This part doesnt work

command = "git clone --mirror org (org) · GitHub
/Users/me/github/splat/`date +%y%m%d`/#{repo_name}/"
  exec command

As I understand it when the backticks are used it opens a sub shell, how
can I get that directory name?

--
Posted via http://www.ruby-forum.com/\.

Thank you! That worked great

···

--
Posted via http://www.ruby-forum.com/.

Seems to be going a long way 'round something pretty simple.

today = Time.now.strftime("%Y%m%d")
save_path = "/Users/me/github/splat/#{today}"
system("mkdir -p #{save_path}")

You can create the directories without relying on shell commands:

require 'fileutils'
FileUtils.mkdir_p(save_path)

···

Am 02.12.2012 03:14, schrieb tamouse mailing lists:

# ... later

system("git clone --mirror org (org) · GitHub
#{save_path}/#{repo_name}")

Adjust scope on variables as necessary...

--
<https://github.com/stomar/&gt;

tamouse mailing lists wrote in post #1087485:

···

On Sat, Dec 1, 2012 at 7:19 PM, Pierre-Andre M. <lists@ruby-forum.com> > wrote:

Seems to be going a long way 'round something pretty simple.

today = Time.now.strftime("%Y%m%d")
save_path = "/Users/me/github/splat/#{today}"

system("mkdir -p #{save_path}")

FileUtils.mkdir_p(save_path)

--
Posted via http://www.ruby-forum.com/\.

\o/

There's almost *always* a way to do something in ruby without
resorting to forking another process.

···

On Sun, Dec 2, 2012 at 2:38 AM, 7stud -- <lists@ruby-forum.com> wrote:

tamouse mailing lists wrote in post #1087485:

On Sat, Dec 1, 2012 at 7:19 PM, Pierre-Andre M. <lists@ruby-forum.com> >> wrote:

Seems to be going a long way 'round something pretty simple.

today = Time.now.strftime("%Y%m%d")
save_path = "/Users/me/github/splat/#{today}"

system("mkdir -p #{save_path}")

FileUtils.mkdir_p(save_path)