need explain

Dear unix team

i'm user for a system build on unix system ,so we need to run a lot of scripts not in one sission but every script on the associated terminal , so the script name = the name of the terminal which will run this script on it . and someone create a batch that make as below :
1- but all scripts need to run in one folder
2- put the created batch with them in the same folder
3- the batch will take the name from the script and open sission on this terminal (terminal name like = mohamed.txt)>> will open sission on mohamed and run the script mohamed.txt

i attached the batch so i need your help to explain how the batch do this and how it take the name of the script

The script executes the commands in Template.txt on all remote machines found in Template_Elements.txt and long as <machine>.txt exists.

These three files (Template.txt Template_Elements.txt and <machine>.txt) should exist in the same directory as moh_modified.sh.

The command that does this is:

batch_rlogin $bsc < $dir/$bsc.txt >> $dir/$bsc.out

$bsc above is the machine name, and $dir is the directory that the script is in.

So you can see the command batch_rlogin is called with the machine name as a parameter and takes input form $dir/<machine>.txt and output goes to $dir/<machine>.out in the current directory.

Dear Chubler_XL

thanks for your explination

Dear Chubler_XL

kindly can you explain the lines in the same attached script:

for i in "$dir"/*.txt
do
echo ${i%%} | sed 's#^.*/##' | sed 's/\.//' | sed 's/txt//' | cat >> $dir/Network_Elements.out
done
filename=$dir/Network_Elements.out

and tell me how it run all the scripts for remote machines in parallel

thanks alot

So What I understand you need to run script around lot of servers parallel. Copy the scrip to all servers and put in cron etc .... if you feel the script changes all the time then use

  1. scp to copy script to all servers .
  2. set at job or cron using ssh once scp is done.

About the script which you asked ... looks like it is trying to get rid of .txt extensions from all file in $dir directory ...

Here is a easy way you can replicate ...

  1. go to test server/tmp/where you cannot harm server
    [very imp]
  2. copy the lines in a file
  3. make it executable
  4. make/copy some .txt files from production server

Now you can see what happns

You should learn some bash scripting and sed . what I can see in script is script is basically checking some file and batch_rlogin might be script/alias which external to this script.

Contact me if you need more help