Shell Script Problems


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script Problems
# 1  
Old 12-09-2014
Shell Script Problems

Hi,

I'm newbie in the shell script world and i want to solve some problems I am experiencing.
My main goal is to create a ksh script to use 2 text files as input to execute a local shell script(create user commands in the criar.users.aix file) through a ssh connection in which the list of machines is in the maquinasaix file and each userinfo is a line on the second file(userinfoaix)

The problematic piece of script is the following:
"
Code:
....


                listainfo="$(cat ./userinfoaix)"
                listamaq="$(cat ./maquinasaix)"

                for i in `$listainfo`;
                do

                    for maquina in `$listamaq`;
                    do
                        cacriar.users.aix | ssh $userdeacesso@$maquina
                    done
            
                done
..

"


Any help is welcome.

Regards,
Joćo Chambino

Last edited by Scrutinizer; 12-09-2014 at 11:09 AM.. Reason: code tags
# 2  
Old 12-09-2014
Consider:
Code:
for i in $(cat ./userinfoaix);
do
    userdeaceso=$i
    for maquina in $(cat ./maquinasaix);
    do
        cacriar.users.aix | ssh $userdeacesso@$maquina
    done

done


1. simply cat the file at the start of the loop. This may not work depending on the format of the file, which we cannot see.

2. userdeacesso was not defined - I set it to $i

3. I am assuming that cacriar.users.aix is a valid, functioning shell script. If you mean to run it on the other machines the syntax you have will not work at all. You have to scp the script over there, then run it using another ssh command

I do not know that any of these changes will work as given, but they address two simple issues. For example, have you set up ssh keys on each remote machine ($maquina) for the use that runs the script? IF not this has to be run interactively.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Problems executing an interactive shell script

I am new to Unix shell and to this forum. I am having some trouble executing an interactive shell script that I have written using Mac TextEdit that takes a user input via terminal of a file type (jpg or gif) and then activates a script that will iterate through a folder of unsorted file types... (4 Replies)
Discussion started by: Braveheart
4 Replies

2. AIX

executable problems with shell script in IBM servers

We have a java stand alone application running currently on sun Solaris system. The java application runs on Jdk 1.4. We are reshooting this java application to new Ibm servers. There are 10 unix scripts for this application. All scripts works well except one shell script, This shell... (2 Replies)
Discussion started by: poojagupta
2 Replies

3. Shell Programming and Scripting

Remotely Executing Shell Script - Problems

Hey Lads, I have a shell script on a remote Server X that i need to execute from Server A. the script executes fine locally but remotely does not. It appears the script on the remote machine is calling another shell script which only has an array defined . Please see below the errors. ... (10 Replies)
Discussion started by: Irishboy24
10 Replies

4. Shell Programming and Scripting

Problems with storing oracle sqlplus query output shell script

Hello everyone, I have a RHEL 5 system and have been trying to get a batch of 3-4 scripts each in a separate variables and they are not working as expected. I tried using following syntax which I saw a lot of people on this site use and should really work, though for some reason it doesn't... (3 Replies)
Discussion started by: rockf1bull
3 Replies

5. Shell Programming and Scripting

Execution problems with BASH Shell Script

Hi I need help with my coding , first time I'm working with bash . What i must do is check if there is 3 .txt files if there is not 3 of them i must give an error code , if al three is there i must first arrange them in alphabetical order and then take the last word in al 3 of the .txt files... (1 Reply)
Discussion started by: linux newb
1 Replies

6. UNIX for Dummies Questions & Answers

Problems in shell script if sed is used

Hi All, Below is the script which i have written in cygwin: #!/usr/bin/sh fname=$1 cat $fname | sed 's/ //g' > fname1 for i in `cat $fname1` do echo $i > file1 #param1 is script name param1=`awk -F , '{print $1}' file1` param1="$param1.sql" #param2 is BL param2=`awk -F , '{print... (5 Replies)
Discussion started by: janardhanamk
5 Replies

7. Shell Programming and Scripting

shell script to call perl script problems

Ok, don't ask me why, but all calls to perl must be called by a shell script. Its really not ideal, but its what I have to work with. Calling it isnt the issue, its passing in the arguments. I have about 1000 perl scripts to call by a shell script. Right now, I'm executing the shell script... (3 Replies)
Discussion started by: regexnub
3 Replies

8. OS X (Apple)

Execution Problems with ASU Shell Script

Hello. I have been trying to create a shell script that checks to see if there are software updates and if not, then exit the script. If so, then check to see if a user is logged in. If a user is logged in, it will only install the updates. If a user is not logged in, then it will display a... (3 Replies)
Discussion started by: Talcon
3 Replies

9. Solaris

Problems with korn shell script

Hey Guys, I'm looking for some advice about a korn shell script I've written. I've spent hours googling for an answer hopefully someone here can help me out. Basically the part of the script I'm having problems with is when I need to SFTP a file from one server to another. The line looks... (6 Replies)
Discussion started by: hilather
6 Replies

10. Shell Programming and Scripting

Shell script problems to do

Does anyone know a good site to do shell script problems? (0 Replies)
Discussion started by: cleansing_flame
0 Replies
Login or Register to Ask a Question