Sponsored Content
Top Forums Shell Programming and Scripting Array declared in shell script works for AIX but fails in Linux Post 303044316 by mohtashims on Wednesday 19th of February 2020 02:15:18 AM
Old 02-19-2020
Array declared in shell script works for AIX but fails in Linux

Array declared in shell script works for AiX 6.1 and above but fails in Linux CentOS 7.

I have the below code for Array in my shell script that runs fine on AiX systems.

Note: on AiX it uses ksh shell while on Linux it uses non ksh shell.

Code:
set -A filelist

However, i now wish to use the same shell script on both AiX and Linux.

On Redhat Linux CentOS 7 the above code fails as below:

Code:
-bash-4.2$ set -A filelist
-bash: set: -A: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]

I want the array declaration to work on both AiX and Linux systems.

How is it possible to achieve ?

Last edited by mohtashims; 02-19-2020 at 04:05 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script: Bind variable not declared

Hi Friends, I am trying to run a sql query from shell script as below but I get "Bind variable "1" not declared" error. 1.sh shell script has following: sDb="abc/xyz@aaa" a="1.sql" sqlplus -s $sDb @$a $1 1.sql file has following: spool Result.tmp append select cust_name from orders... (1 Reply)
Discussion started by: ppat7046
1 Replies

2. Shell Programming and Scripting

Help wth Net::FTP in script sometimes fails but wsftp always works

Hi, I have a script that transfers files from a Solaris server to target unix servers. The script uses Net::FTP->put to write the files, which can be any number of files, not always the same. This script works flawlessly to many servers. For one particular instance of the script,... (3 Replies)
Discussion started by: csgonan
3 Replies

3. Shell Programming and Scripting

Assign user input to already declared array

What I am doing is creating a top menu, which a user will select a choice with a number entry. That number corresponds to a string in an array. I then want to assign that response to another array I've already declared. For example: #!/bin/bash colors=(red blue yellow) red=(cherry fire)... (2 Replies)
Discussion started by: Akilleez
2 Replies

4. Shell Programming and Scripting

awk regex expression works in AIX but not in Linux

I have following expression: echo "Sun 12 Jul BST 2014\nSun 12 Jul 2014\nSun 12 Jul IS 2014" | awk '/(Sun)+( 12)+( Jul )+({3} )?(2014)/{print;}' I ran above code in AIX box and output is as follows Sun 12 Jul BST 2014 Sun 12 Jul 2014 I ran above code in Linux box and output is as... (8 Replies)
Discussion started by: kamlesh_pradhan
8 Replies

5. Shell Programming and Scripting

Grep works on Linux but fails on Solaris

Hi, On linux i have the below command working fine. grep -o '<name>.*</name>' deploy.tmp | sed 's/\(<name>\|<\/name>\)//g' deploy.tmp But the same is failing on Solaris uname -a SunOS mymac 5.10 Generic_150400-23 sun4v sparc sun4v Can you tell me how can i get it work on Solaris ?... (6 Replies)
Discussion started by: mohtashims
6 Replies

6. Shell Programming and Scripting

awk works on Linux but fails on Solaris

On linux i have the below command working fine. awk '/<app-deploy>/{A=1;++i} /<\/app-deploy>/{print >> "found"i".tmp";A=0} A{;print >> "found"i".tmp"}' deploy.xml But the same is failing on Solaris Output: awk: syntax error near line 1 awk: bailing out near line 1 uname -a SunOS mymac 5.10... (5 Replies)
Discussion started by: mohtashims
5 Replies

7. Shell Programming and Scripting

sed works on Linux but fails on Solaris

Hi, On Linux i get the desired ouput: echo "<value>WEB_USER</value>" | sed 's/\(<value>\|<\/value>\)//g'Output: Executing the same command on Solaris: echo "<value>WEB_USER</value>" | sed 's/\(<value>\|<\/value>\)//g'Output: I need to get the desired output on Solaris i.e. WEB_USER and... (4 Replies)
Discussion started by: mohtashims
4 Replies

8. UNIX for Beginners Questions & Answers

Linux shell | how to exit a script if any command fails.

Hi, i am new here let me say HI for all. now i have a question please: i am sending one command to my machine to create 3 names. if one of the names exists then the box return error message that already have the name but will continue to create the rests. How i can break the command and... (7 Replies)
Discussion started by: Amiri
7 Replies

9. Shell Programming and Scripting

Find command works on Linux but fails on Solaris.

Hi, I am looking for a generic find command that works on both Linux and Solaris. I have the below command that works fine on Linux but fails on solaris.find /web/config -type f '(' -name '*.txt' -or -name '*.xml' -name '*.pro' ')' Fails on SunOS mysolaris 5.10 Generic_150400-61 sun4v sparc... (1 Reply)
Discussion started by: mohtashims
1 Replies

10. Shell Programming and Scripting

Replace string works on command-line but fails when run from shell script

I wish to replace "\\n" with a single white space. The below does the job on command-line: $ echo '/fin/app/scripts\\n/fin/app/01/sql' | sed -e 's#\\\\n# #g'; /fin/app/scripts /fin/app/01/sql However, when i have the same code to a shell script it is not able to get me the same output:... (8 Replies)
Discussion started by: mohtashims
8 Replies
exit(1) 							   User Commands							   exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 03:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy