Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 905125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:09:51+00:00 2026-05-15T16:09:51+00:00

I have the following Ruby script that creates a Debian package, which works fine:

  • 0

I have the following Ruby script that creates a Debian package, which works fine:

#!/usr/bin/ruby

  dest = "#{File.dirname(__FILE__)}/../build"
  package = "foo"

  [
    "cd #{dest} && tar czvf data.tar.gz bin console data.sql etc filter install.rb",
    "cd #{dest} && tar czvf control.tar.gz control",
    "cd #{dest} && echo 2.0 > debian-binary",
    "cd #{dest} && ar -cr #{package}.deb debian-binary control.tar.gz data.tar.gz",
    "cd #{dest} && mv #{package}.deb ..",
    "cd #{dest} && rm data.tar.gz control.tar.gz",
  ].each do |command|
    puts command
    system(command)
  end

Is there a way in Ruby where I can leave off the “cd #{dest} &&” part of each command?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:09:52+00:00Added an answer on May 15, 2026 at 4:09 pm
    Dir.chdir(dest) do
      # code that shall be executed while in the dest directory
    end
    

    Dir.chdir when invoked with a block will change to the given directory, execute the block and then change back.

    You can also use it without a block, in which case it will never change back.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: #!/usr/bin/ruby class Person def self.speak p = self.new puts
I have the following Ruby script: require 'nokogiri' require 'erb' listing = %Q{<% listing
I am trying to install ruby-mp3info. I have the following URL from which I
I have the simple following code, which is working in a ruby (not rails)
Does anyone have or know of a Ruby script that converts text to html?
I have a ruby script repeatedly executing the following the INSERT statement using the
I have the following test Ruby script: require 'tempfile' tempfile = Tempfile.new 'test' $stderr.reopen
I have a Ruby script in my Rails app that I use to load
I have implemented Ruby C extension(i.e. Invoking C function from ruby script) Following is
I have a Ruby script that generates a sed command to replace some PHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.