execute multiple commands on console through unix shell

jhwang

I am currently trying to figure out if it is possible to run multiple commends within one line on a rails console through Unix shell or within a ruby script.

For Example:

exec('echo p = Product.first;b = Billing.first|rails c')

When I tried something similar to the example, it would always try to execute the two commands before launching console.

Hope this make sense and appreciate any help I can get.

Thanks in advance!

Devin Howard

Yes you can do this

From a unix shell prompt:

echo 'p = Product.first; b = Billing.first' | rails c

From the rails console itself, or a ruby script I guess:

exec(%Q{echo 'p = Product.first; b = Billing.first' | rails c})

It's probably worth asking why you want to do this though. Could you use a rake task?

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to execute mongo commands through shell scripts?

From Dev

How to execute the vim commands through shell script

From Dev

Execute multiple unix commands from SAS

From Dev

Bash script to execute multiple Unix commands

From Dev

C++ execute multiple commands with timer in shell

From Dev

How do I execute shell commands through eggPlant on Windows?

From Dev

Execute shell commands in Python

From Dev

A better way to execute multiple MySQL commands using shell script

From Dev

how to Execute multiple shell commands in tsystem component talend

From Dev

Jenkins - Execute shell commands with wildcards

From Dev

execute commands as parameters in a login shell

From Dev

Multiple shell commands in Windows

From Dev

Multiple shell commands in Windows

From Dev

Jenkins - can the "Execute Shell" execute SSH commands

From Dev

Execute Unix commands using putty in C#

From Dev

Execute Unix commands using putty in C#

From Dev

Read deadlock when using pipes to execute multiple shell commands on the same process

From Dev

How to execute the multiple commands with && operator in new lines(not all in single line) :shell script

From Dev

Execute multiple commands after [ test

From Dev

Delphi - CreateProcess - Execute multiple commands

From Dev

Execute multiple commands after [ test

From Dev

Running a .sh to execute multiple commands

From Dev

execute multiple commands after ssh

From Dev

Verify network identity through unix commands

From Dev

How to execute console commands on google appengine?

From Dev

Java: Open console programmatically and execute commands from it

From Dev

How to execute VSTest.Console.exe using a shell script with multiple filenames

From Dev

Unable to execute Unix command through Java code

From Dev

How to execute terminal commands through scala

Related Related

  1. 1

    How to execute mongo commands through shell scripts?

  2. 2

    How to execute the vim commands through shell script

  3. 3

    Execute multiple unix commands from SAS

  4. 4

    Bash script to execute multiple Unix commands

  5. 5

    C++ execute multiple commands with timer in shell

  6. 6

    How do I execute shell commands through eggPlant on Windows?

  7. 7

    Execute shell commands in Python

  8. 8

    A better way to execute multiple MySQL commands using shell script

  9. 9

    how to Execute multiple shell commands in tsystem component talend

  10. 10

    Jenkins - Execute shell commands with wildcards

  11. 11

    execute commands as parameters in a login shell

  12. 12

    Multiple shell commands in Windows

  13. 13

    Multiple shell commands in Windows

  14. 14

    Jenkins - can the "Execute Shell" execute SSH commands

  15. 15

    Execute Unix commands using putty in C#

  16. 16

    Execute Unix commands using putty in C#

  17. 17

    Read deadlock when using pipes to execute multiple shell commands on the same process

  18. 18

    How to execute the multiple commands with && operator in new lines(not all in single line) :shell script

  19. 19

    Execute multiple commands after [ test

  20. 20

    Delphi - CreateProcess - Execute multiple commands

  21. 21

    Execute multiple commands after [ test

  22. 22

    Running a .sh to execute multiple commands

  23. 23

    execute multiple commands after ssh

  24. 24

    Verify network identity through unix commands

  25. 25

    How to execute console commands on google appengine?

  26. 26

    Java: Open console programmatically and execute commands from it

  27. 27

    How to execute VSTest.Console.exe using a shell script with multiple filenames

  28. 28

    Unable to execute Unix command through Java code

  29. 29

    How to execute terminal commands through scala

HotTag

Archive