Sponsored Content
Top Forums Shell Programming and Scripting [Solved] Run multiple commands in invoked program Post 302765737 by tz742 on Sunday 3rd of February 2013 08:54:26 AM
Old 02-03-2013
[Solved] Run multiple commands in invoked program

Hi,
I have coded a program in Haskell using the compiler Hugs and the program requires multiple commands (with parameters) to be entered into it, it then outputs the result of its execution. I need to test a lot of different options (i.e. the parameters) so it would be obvious to automate the process. Using BASH I have managed to invoke the program and pass it a command, but only 1 command is executed and then the program closes.

How do I process sequential commands in the program from the script and then store the output of the execution, and then loop the process to test different parameters?

The program in question is invoked like this, followed by the commands, with the output following the last command:

Code:
$ hugs Net.hs
Net> command1 params
Net> command2 params
etc.
Net> lastcommand params
{output is displayed}

Thanks for your help.


EDIT:

I just worked out a solution, for anyone who has this similar problem here is my solution:

Code:
echo -e "command 1 params\ncommand2 params" | hugs Net.hs


Last edited by radoulov; 02-03-2013 at 04:05 PM.. Reason: Solution found
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Command to run multiple commands from a file.

I need a command, which could run mutliple commands from a file. Let's say, I have mv fileA1 fileB1 mv fileA2 fileB2 ..... mv fileA20 fileB20 I put these commands in a file, then I need a command to run the file as a whole so that I don't need to type 20 times... Anyone tell me how to... (8 Replies)
Discussion started by: kaixinsjtu
8 Replies

2. Shell Programming and Scripting

Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
Discussion started by: SN2009
6 Replies

3. Shell Programming and Scripting

Run multiple commands in $() without opening a new shell

The code below works, but takes too many lines and looks awkward: db2 "export to $filename of del select * from $table with ur"|tee -a $LOGFILE|awk '/Number of rows exported:/ {print $5}' > numrows.tmp numrows=$(cat numrows.tmp) rm numrows.tmp When I try the... (2 Replies)
Discussion started by: akar_naveen
2 Replies

4. UNIX for Dummies Questions & Answers

How to run two commands from a exec call in a c program

Hi, I have to run two commands one after another from a c program. How can i do this with exec system calls. i tried giving them as argument to execv but it is not working.please help thanks (3 Replies)
Discussion started by: suryashikha
3 Replies

5. Shell Programming and Scripting

Shell script to run a python program on multiple entries in a file

Hello I am trying to run a python program using shell script, which takes a single argument from a file. This file has one entry per line : 1aaa 2bbb 3ccc 4ddd 5eee ... ... ... My shell script runs the program, only for the last entry : #!/bin/sh IFS=$'\n' for line in $(cat... (2 Replies)
Discussion started by: ad23
2 Replies

6. UNIX for Dummies Questions & Answers

How to run multiple piped commands in a find -exec statement?

I can't get this to work. Running a single command works fine: find . -name "*.dat" -exec wc -l '{}' \; gives me the file name and number of lines in each .dat file in the directory. But what if I want to pipe commands, e.g. to grep something and get the number of lines with that pattern... (3 Replies)
Discussion started by: DJR
3 Replies

7. SuSE

Allow multiple users to run several root commands

I am using SUSE Linux Enterprise Server 10 SP2 (i586) and I had earlier ammended my sudoers file to allow users to become root user with "sudo su - " command Now I am trying to add multiple users to the sudoers file to run several commands such as restarting the server, restarting the nagios... (9 Replies)
Discussion started by: hedkandi
9 Replies

8. UNIX for Dummies Questions & Answers

Run multiple commands

Hi All, Is it possible to run second/multiple commands at a time in script before the completion/return of first command? Pls reply. (5 Replies)
Discussion started by: cns1710
5 Replies

9. Shell Programming and Scripting

[Solved] Usage of shell commands inside a C program

Hi I have a program int main(int srgc, char *argv) { for(int i=1; i<50; i++) { system("dd if=/dev/zero of=file$i bs=1024 count=$i"); } return 0; } My doubt is how to use the "$i" value inside C code Please help (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

10. Shell Programming and Scripting

Run multiple commands in ssh

Hi All, I have the below requirement. I want to copy the local file to remote after that i need to run the local script on a remote machine.When i use two ssh commnds i can achieve this. But i want to achieve this using one ssh command. Below command to copy the local file to remote ssh -q... (2 Replies)
Discussion started by: mohanalakshmi
2 Replies
Net::DBus::GLib(3pm)					User Contributed Perl Documentation				      Net::DBus::GLib(3pm)

NAME
Net::DBus::GLib - Perl extension for the DBus GLib bindings SYNOPSIS
####### Attaching to the bus ########### use Net::DBus::GLib; # Find the most appropriate bus my $bus = Net::DBus::GLib->find; # ... or explicitly go for the session bus my $bus = Net::DBus::GLib->session; # .... or explicitly go for the system bus my $bus = Net::DBus::GLib->system DESCRIPTION
Net::DBus::GLib provides an extension to the Net::DBus module allowing integration with the GLib mainloop. To integrate with the main loop, simply get a connection to the bus via the methods in Net::DBus::GLib rather than the usual Net::DBus module. That's it - every other API remains the same. EXAMPLE
As an example service using the GLib main loop, assuming that SomeObject inherits from Net::DBus::Service my $bus = Net::DBus::GLib->session(); my $service = $bus->export_service("org.designfu.SampleService"); my $object = SomeObject->new($service); Glib::MainLoop->new()->run(); And as an example client my $bus = Net::DBus::GLib->session(); my $service = $bus->get_service("org.designfu.SampleService"); my $object = $service->get_object("/SomeObject"); my $list = $object->HelloWorld("Hello from example-client.pl!"); METHODS
my $bus = Net::DBus::GLib->find(%params); Search for the most appropriate bus to connect to and return a connection to it. For details of the heuristics used, consult the method of the same name in "Net::DBus". The %params hash may contain an additional entry with a name of "context". This can be a reference to an instance of the "Glib::MainContext" object; if omitted, the default GLib context will be used. my $bus = Net::DBus::GLib->system(%params); Return a handle for the system message bus. For further details on this method, consult to the method of the same name in Net::DBus. The %params hash may contain an additional entry with a name of "context". This can be a reference to an instance of the "Glib::MainContext" object; if omitted, the default GLib context will be used. my $bus = Net::DBus::GLib->session(%params); Return a handle for the session message bus. For further details on this method, consult to the method of the same name in Net::DBus. The %params hash may contain an additional entry with a name of "context". This can be a reference to an instance of the "Glib::MainContext" object; if omitted, the default GLib context will be used. SEE ALSO
Net::DBus, Glib, Glib::MainLoop "http://dbus.freedesktop.org", "http://gtk.org" AUTHOR
Daniel Berrange <dan@berrange.com> COPYRIGHT
Copyright 2006-2008 by Daniel Berrange perl v5.14.2 2008-01-08 Net::DBus::GLib(3pm)
All times are GMT -4. The time now is 09:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy