ballouta Posted April 13, 2014 Share Posted April 13, 2014 Hi I am frustrated from this simple task, I've been testing this script for two hours trying to find the problem but no luck! My script reads a command line argument(ARGV[0]), then creates a directory named as #{ARGV[0]}, then it reads the DATA object (after the __END__ which looks below), and create those directories inside ARGV[0] __END__app/views/layoutsapp/modelsapp/controllersconfigdbdoclibpublic/javascriptspublic/stylesheetspublic/imageslog note that I am using Notpad++ and i have EOL set to UNIX, so it is NOT supposed to cause any \n troubles My script creates what looks like directories, i can see them in my FTP but I can't delete any! when I asked my instructor about it, he said, review your code, lib (directory) is NOT like lib? so I am wondering where did the question mark come from? also note that I do NOT see ? when i use SSH client or FTP! i had to run another script to delete these weird directories this is my script require 'fileutils' include FileUtils if ARGV.empty? puts "__________________________________________ _ _" puts " " puts "USAGE: ruby script/generate.rb Your_Site_Name" puts "__________________________________________ _ _" elsif Dir.exists?("/home/students/myname/public_html/cis113/#{ARGV[0]}") puts "This directory already exist!" puts "Would you like to use the existing directory (Y/N)?" #I need help with this part later #read DATA and create directories else Dir.mkdir("/home/students/myname/public_html/cis113/#{ARGV[0]}") DATA.each do |line| FileUtils.mkpath ("/home/students/myname/public_html/cis113/#{ARGV[0]}/#{line}") end end help is highly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/287745-ruby-creating-directories-in-a-loop/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.