Sponsored Content
Top Forums Shell Programming and Scripting How to run several bash commands put in bash command line? Post 303011747 by rbatte1 on Tuesday 23rd of January 2018 06:11:47 AM
Old 01-23-2018
What you originally have is more like saying "Run echo ${PATH} in the background and (ignoring if it works or not) run echo have a nice day! in the foreground"

Your output may not always be consistent. In this very simple case it probably always will be but more complex calls could have the output from either displayed first or even interleaved if you have two long running processes that output multiple lines. Can you tell us what you are trying to achieve here?


If you have a cmd1 ; cmd2 ; cmd3, these run sequentially. There is no return code checking done, it just runs one after the other.

If you have a cmd1 & cmd2 & cmd3 &, these run in the background (so disconnected from your STDIN (usually keyboard) and may independently write output to STDOUT (usually screen) ) and because cmd3 has a trailing & putting it in the background, you get dropped back to the shell (or calling program) and can carry on with other work. This may or may not be what you wanted.

If you have a mixture then you have to interpret what will happen. You can also add conditional execution, so cmd1 && cmd2 || cmd3 will run cmd1. If there is a zero return code (deemed as success) then run cmd2. If either cmd1 or cmd2 have a non-zero return code (deemed as a failure) then run cmd3

This can be quite compact but often can get complicated to interpret, so most people a re more explicit with something more like:
Code:
cmd1
RC=$?
if [ $RC -eq 0 ]
then
   cmd2
   RC=$?
fi

if [ $RC -ne 0 ]
then
   cmd3
fi


Does this help, or just confuse? Apologies if it is the latter.


Robin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to make your bash script run on a machine with csh and bash

hi, i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Discussion started by: npatwardhan
3 Replies

2. Shell Programming and Scripting

how to run non-standard commands in bash script?

Hello All. I suspect that this will be a clear noob question, but I haven't been able to figure it out using the usual methods, so I turn to you. I've written a script to create input files for the quantum chemistry program NWCHEM. Generally you create an input file and then execute it by... (12 Replies)
Discussion started by: EinsteinMcfly
12 Replies

3. AIX

Typing "bash" at the command line spawns two bash processes

Server: IBM p770 OS: AIX 6.1 TL5 SP1 When one of our develoeprs types "bash" on the command line to switch shells, it hangs. For some reason, two bash processes are created....the first bash process spawns a second bash process in the same console, causing a hang. Anyone have any idea what... (2 Replies)
Discussion started by: wjssj
2 Replies

4. Shell Programming and Scripting

[bash] run a shell who runs commands

Hi all. On X11 I'm on a shell ...shell_1 (/bin/bash). From here I want to open another shell window shell_2 who executes commands like "ls -l" or programs like ". /program"... so the "result" of commands shows in shell_2 window and not in shell_1. Is that possible ? (4 Replies)
Discussion started by: jerold
4 Replies

5. Shell Programming and Scripting

How i can put the result of a command inside a bash variable?

#!/bin/bash #... for i in `ls -c1 /usr/share/applications` do name="cat $i | grep ^Name= | cut -d = -f2" echo $name #... done Now inside name as output is present: while i want only the result of the command. Ideally i would like obtain that information using only bash ... or... (8 Replies)
Discussion started by: alexscript
8 Replies

6. Shell Programming and Scripting

Bash if run a command

I am having trouble with bash. I am trying to put a command in an if statement and then compare it to a string. This works perfectly. echo $(ipcs | grep Shared | awk '{print $2}')When I put it in an if statement I get some problems. $ if ; then echo expression evaluated... (10 Replies)
Discussion started by: cokedude
10 Replies

7. Shell Programming and Scripting

Put a command into router through sshpass bash script

hello, i am facing some issue. I am using a simple bash script that via sshpass put a command into router. Now, problem is that i have a file and commands into it. sshpass -p $pass ssh -o $log -n $user@$h /ip address set address=10.0.0.1/24 so if I have that command ip address set ... (0 Replies)
Discussion started by: tomislav91
0 Replies

8. Solaris

Run automated bash commands from sh login shell

I use plink.exe to automate remote commands that return data to Windows machines. This works well on newer servers running Red Hat since the commands were developed for bash and the designated user's login shell is bash. I need to also support older servers which are running Solaris 10 but the... (5 Replies)
Discussion started by: randman1
5 Replies

9. Shell Programming and Scripting

Run command through html+cgi in bash

Hi everyone, I want to kill process through the web, so I create html page with single bottom that run kill command in shell script with CGI. Here is html code: <td><form METHOD="GET" action="http://IP:port/cgi_bin/script.cgi" > <input type="submit" value= "Submit" > <INPUT name="q"... (7 Replies)
Discussion started by: indeed_1
7 Replies

10. UNIX for Beginners Questions & Answers

Compilation error when I run Bash configuration command

Hi, I downloaded source code file from The GNU website and changed the source code of ls.c file, added printf command to it. It worked fine. Then, I deleted the printf command, saved the file and ran the command 'make sudo && make install' closed the terminal and printf statement went away. I... (1 Reply)
Discussion started by: akanksha1509
1 Replies
GVHDL(1)							   User Commands							  GVHDL(1)

NAME
gvhdl - Frontend to the VHDL compiler/simulator FreeHDL. SYNOPSIS
gvhdl [OPTION] ... [VHDL_FILES] ... [OBJECT_FILES] ... DESCRIPTION
FreeHDL is a compiler/simulator suite for the hardware description language VHDL. VHDL'93 as well as VHDL'87 standards are supported. FreeHDL translates the original VHDL source FILEs into C++. Then, the C++ source can be compiled and linked to the kernel to build the sim- ulation program. Starting the generated executable will simulate the corresponding VHDL model. The actual build process to generate the simulator from the VHDL source is a complex process which is handled by the gvhdl script. VHDL_FILES is a list of VHDL source file names that must end with .vhdl or .vhd. The first VHDL file name also determines the name of the simulator executable. This is, the final executable will be named after the first VHDL file without the .vhdl or .vhd extension. Note that the object files as well as the simulator will be created in the current directory. OBJECT_FILES specifies a list of object files that are linked to the simulator executable. gvhdl considers all files that end with .o to be object files. Typically, these object files are generated previously (using option -c) from VHDL source code during a separate compilation step. OPTIONS
-L VHDLLIB Path to VHDL library root directory. Within this directory the compiler search for a file named v2cc.libs. The mapping file v2cc.libs translates library unit names to directories. Note that more than one VHDLLIB may be provided. -g Adds debug information to the executable. In detail, this options associates the generated machine code to the corresponding lines in the VHDL source files. -G Adds debug information to the executable but does not associate machine code to VHDL source lines. This option is actually used to debug the generated C++ code. -c Do not generate simulator executable. Using this option, the compiler translated VHDL source into executables and compiles them into object code but does not generate a final simulator executable. This option is especially useful to compile VHDL packages. -l LIBNAME Associate the VHDL source code to VHDL library LIBNAME. As default the library name WORK is used. This option is especially impor- tant if VHDL components from several VHDL libraries shall be build into the simulator. Note that in order to successfully use a VHDL component from another than the current working library, the corresponding VHDL files must be found by the compiler using the mecha- nisms described in v2cc.libs. Further, components must be compiled with the appropriate -l LIBNAME option. --relaxed-component-visibility Allows invisible default bindings from WORK. --libieee Add the IEEE standard library files to the simulation executable. ENVIRONMENT VARIABLES V2CC_LIBRARY_PATH The variable V2CC_LIBRARY_PATH consists of ":" separated filenames. In addition to the environment variable, you can use the "-L libdir" command line option with v2cc. The directories specified with "-L" are added in front of the ones specified by V2CC_LIBRARY_PATH. In the final library path, they appear in the same order as on the command line. SUPPORTED VHDL SUBSET
Currently, FreeHDL does not support the entire VHDL'93 standard. The following incomplete list gives an overview on what is currently not supported: - Individual association of formals of composite type are not supported. - Shared variables are not supported. - Attributes transaction, quiet, stable and delayed are not supported. - User defined attributes are not supported. - Groups are not supported. - Guarded signal assignments are not supported. - Configurations are not supported. - Currently, drivers cannot be switched off. EXAMPLES
Use gvhdl -c adder.vhdl to build an object file for adder.vhdl. Note that adder.vhdl may contain several VHDL models. gvhdl adder.vhdl will generate a simulator for the last VHDL model found in adder.vhdl. However, in this case, all VHDL components that area required to build the simulator must be included in the VHDL source file. gvhdl top.vhdl adder.o --libieee generates a simulator for the last VHDL model found in top.vhdl by compiling all models in top.vhdl and linking (the previously generated) adder.o object file and the IEEE standard libraries to the executable. gvhdl -c -l mylib adder.vhdl will build an object file including all components provided in adder.vhdl. However, in this case the components will be associated with library mylib instead of the default library name work. Note that option -l does only effect the generated C++ source code but does not alter the place where the object files or executables are stored. SIMULATION COMMANDS
After the simulator has been started a short summary of the available commands is printed to the screen: c <number> : execute cycles = execute <number> simulation cycles n : next = execute next simulation cycle q : quit = quit simulation r <time> : run = execute simulation for <time> d : dump = dump signals doff : dump off = stop dumping signals don : dump on = continue dumping signals s : show = show signal values dv : dump var = dump a signal from the signal lists ds : dump show = shows the list of dumped signals nds : number show = shows the number of dumped signals dc [-f <filename>] [-t <timescale> <time unit>] [-cfg <translation file>] [-q] : configures dump process Note that signals are dumped into a file (default file name is "wave.dmp") in VCD format. This file format should be accepted by each VCD waveform viewer. The file name is set to "wave.dmp" but may be changed using "dc -f <new_file_name>". However, make sure to execute "dc -f ..." before executing "d". SIMULATOR COMMAND LINE OPTIONS
Simulation can be controlled via the command line parameter '-cmd "cmd1; cmd2; ..."' where 'cmd1', 'cmd2', ... are simulation commands as described in the previous section. Note that each command must be separated by ';'. E.g., executing ./top -cmd "d;run 1000 ns;q;" will start simulation program 'top', dump all signals and run simulation for 1000 ns. Finally, simulation is terminated. Actually, the last command 'q;' is optional as the simulator automatically terminates as soon as the last command has been executed. SEE ALSO
freehdl-v2cc(1), freehdl-config(1), v2cc.libs(5) AVAILABILITY
The latest version of FreeHDL can always be obtained from www.freehdl.seul.org REPORTING BUGS
Known bugs are documented within the BUGS file. If your report addresses a parser related topic then contact Marius Vollmer <mvo@zagadka.ping.de>. If it is related to the code generator or compiler then send an email to Edwin Naroska <edwin@ds.e-technik.uni- dortmund.de>. If your are not sure send it to Edwin. He will take care of forwarding your report to the appropriate recipient. COPYRIGHT
Edwin Naroska (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 <edwin@ds.e-technik.uni-dortmund.de> This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. AUTHORS
Written by Marius Vollmer <mvo@zagadka.ping.de> and Edwin Naroska <edwin@ds.e-technik.uni-dortmund.de>. Debian/GNU Linux December 2005 GVHDL(1)
All times are GMT -4. The time now is 08:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy