How To Determine If Syntax Array=( Str1 Str2 Str3 ) To Declare Array Is Valid

Hi, I am creating a Korn shell script and need to create an array where each element corresponds to one line of an input file. Being able to do the following would be awesome: Code:
array=( $(cat file.txt) )

However, I'm finding that not all of my development boxes allow this. Some return this: Code:
ksh: syntax error: `(' unexpected

I suspect this has something to do with the Korn shell version. Does anyone know how I can find out what version is required in order to be able to declare arrays, as above? Or is this an OS version issue?

I would really appreciate any tips on how I can find out the minimum requirements for this syntax to be valid.

Thanks.


Similar Content



Syntax Error: Unexpected End Of File

Hi!
I wrote a script shell about changing IP of the httpd.conf from text file and saving a new httpd.conf file for all IPs in the text file. The code is below, Im using mremote on windows (RHEL Release 5.7), and getting this error:
./script1.sh: line 19: syntax error: unexpected end of file

Please help me about that error. Thanks!

(ps: line 19 is the last line in the code => done < "$filename" )

#!/bin/bash

DATE='date +%Y%m%d_%H:%M:%S'
NAME=httpd_ip_change
EXTENSION=conf
max=10

filename="$1"
while read -r line

for ((i=2; i<=$max; ++i ))

do
touch $NAME$i.$EXTENSION.$DATE

sed "s/<VirtualHost 10.11.92.81:80>/$line/g" ./httpd.conf > $NAME$i.$EXTENSION.$DATE

done < "$filename"

Problem W/.bash Script... Need Help

I'm trying to loop through a query in SQLDeveloper by passing the query a different Period and I'm having a problem getting the syntax correct.

Individually the following works correctly on its own:

Code:
#!/bin/bash
 for i in `seq -f "%02g" 1 5`;
    do
    echo $i
 done

$ ./test.sh
1
2
3
4
5

the following also executes correctly:

Quote:
sqlplus table1/$userpass@Mytable <<EOF
@./sqlcode.sql $i
EOF
but when I try to wrap the loop around my sqlplus command

Code:
#! /bin/sh
userpass=read
for i in `seq -f "%01g" 1 3`;
  do
        sqlplus -S  table1/$userpass@Mytable <<EOF
        @./sqlcode.sql $i
        EOF
done

I get the following error:

./test.sh: line 13: syntax error: unexpected end of file

Does anyone have any ideas on what's going on?

Difference Between Udev And Udevadm

Hi. I am relatively new to linux systems. I recently jumped on an endeavor to install a vanilla kernel (3.18.5) from the kernel website. Its Documentation/Changes file mentions the minimum version requirements of the packages needed. For udev, it mentioned Code:
udevd --version

to check the version number. But looking around I found for Fedora its Code:
udevadm --version

(I'm using Fedora Workstation 21 64-bit). Is there any fundamental difference between these two utilities? Any explanation would be helpful.

Stdout, Stderr And Redirection -- What Is The Correct Order Or Format ?

Hi all,

Been reading on stdin, stdout and stderr and encounter 2 questions, hope gurus here can advise.

0 = stdin
1 = stdout
2 = stderr

Code:
Sun Dec 21 03:53:42 SGT 2014 > cat test5.sh
#!/bin/bash

echo "Please enter value for name :"
read name
echo "Your name is $name."

echo "Next echo will be a syntax error"
ehco

Code:
Sun Dec 21 03:53:46 SGT 2014 > test5.sh 1> output.txt 2> error.txt
Noob

Sun Dec 21 03:54:56 SGT 2014 > cat output.txt
Please enter value for name :
Your name is Noob.
Next echo will be a syntax error

Sun Dec 21 03:55:23 SGT 2014 > cat error.txt
/home/alan/scripts/test5.sh: line 8: ehco: command not found
Sun Dec 21 03:55:26 SGT 2014 >

Which so far all is good and the correct way to output everything including error to a single file is

Code:
Sun Dec 21 03:59:14 SGT 2014 > test5.sh > output.txt 2>&1


Q1) How is a command being interpreted in linux , the sequence in which it is interpreted ? from left to right ? right to left ?

Shouldn't it be

Code:
test5.sh 2>&1 1>output.txt 
or 
test5.sh 2>&1>output.txt ?

Regards,
Noob

Find 30 Days Old And Delete Prints Error Msg File Not Found After Deleting It

I have a shell script to find folders which are 25 days older and delete it, and put the deleted folder details into log file like this

Code:
 find /ahome/xxx/$FOLDER -type d -mtime +25  -exec ls -ld {} \;  -exec rm -rf {} \;  >> mylogfile.log

after running this command it deletes the folder and logs the folder deleted. But also print error msg
Code:
find: /ahome/prksh/dir/test: No such file or directory

How to suppress the error msg

Degraded RAID 1 Mdadm

I have a degraded software RAID 1 array. md0 is in a state of clean, degraded while md1 is mounted in read-only and clean. I'm not sure how to go about fixing this. Any ideas?

cat /proc/mdstat
Code:
Personalities : [raid1] 
md1 : active (auto-read-only) raid1 sdb2[1] sda2[0]
      3909620 blocks super 1.2 [2/2] [UU]
      
md0 : active raid1 sda1[0]
      972849016 blocks super 1.2 [2/1] [U_]
      
unused devices: <none>

mdadm -D /dev/md0
Code:
/dev/md0:
        Version : 1.2
  Creation Time : Tue Jun 21 21:31:58 2011
     Raid Level : raid1
     Array Size : 972849016 (927.78 GiB 996.20 GB)
  Used Dev Size : 972849016 (927.78 GiB 996.20 GB)
   Raid Devices : 2
  Total Devices : 1
    Persistence : Superblock is persistent

    Update Time : Tue Jun  2 02:21:12 2015
          State : clean, degraded 
 Active Devices : 1
Working Devices : 1
 Failed Devices : 0
  Spare Devices : 0

           Name : 
           UUID : 
         Events : 3678064

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       2       0        0        2      removed

mdadm -D /dev/md1
Code:
/dev/md1:
        Version : 1.2
  Creation Time : Tue Jun 21 21:32:09 2011
     Raid Level : raid1
     Array Size : 3909620 (3.73 GiB 4.00 GB)
  Used Dev Size : 3909620 (3.73 GiB 4.00 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Sat May 16 15:17:56 2015
          State : clean 
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : 
           UUID : 
         Events : 116

    Number   Major   Minor   RaidDevice State
       0       8        2        0      active sync   /dev/sda2
       1       8       18        1      active sync   /dev/sdb2

Issues With RAID- Creating As /dev/md127 Instead Of What's In The Config

Hi,
Recently, I decided to change my partition scheme for my home server. I had a RAID0 that previously spanned three disks and now I only want it to span two. Getting rid of the old one was easy. But getting the new one to work has been a real pain.

It's running Debian Jessie.

For starters, here's my /etc/mdadm/mdadm.conf:
Code:
root@maples-server:~# cat /etc/mdadm/mdadm.conf 
# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#

# by default (built-in), scan all partitions (/proc/partitions) and all
# containers for MD superblocks. alternatively, specify devices to scan, using
# wildcards if desired.
#DEVICE partitions containers
DEVICE /dev/sdb1 /dev/sdc1

# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes

# automatically tag new arrays as belonging to the local system
HOMEHOST <system>

# instruct the monitoring daemon where to send mail alerts
MAILADDR root

# definitions of existing MD arrays

ARRAY /dev/md0 metadata=1.2 UUID=032e4ab2:53ac5db8:98806abd:420716a5 devices=/dev/sdb1,/dev/sdc1

As you can see, I have it specified to setup the RAID as /dev/md0. But every time I reboot, my /proc/mdstat shows:
Code:
root@maples-server:~# cat /proc/mdstat 
Personalities : [raid0] 
md127 : active raid0 sdc1[1] sdb1[0]
      488016896 blocks super 1.2 512k chunks
      
unused devices: <none>

I can confirm that it's actually md127 by looking at /dev:
Code:
root@maples-server:~# ls -l /dev/md*
brw-rw---- 1 root disk 9, 127 May  2 20:17 /dev/md127

/dev/md:
total 0
lrwxrwxrwx 1 root root 8 May  2 20:17 maples-server:0 -> ../md127

And here's a bit more info:
Code:
root@maples-server:~# mdadm --detail --scan
ARRAY /dev/md/maples-server:0 metadata=1.2 name=maples-server:0 UUID=032e4ab2:53ac5db8:98806abd:420716a5

I've tried adding all sorts of options to /etc/mdadm/mdadm.conf, ranging from just the output of the above command (only changing "/dev/md/maples-server:0" to "/dev/md0") to what you see at the top. Nothing seems to be making a difference.

Does anyone have any ideas?

Repo Syntax Issue Rhel/centos

Hello again,

i need to understand once for all the syntax of files.repo.

When i need a repository i create under /etc/yum.repos.d/ the repository file

goofy.repo

with this syntax

[repository_name]
[goofy]
baseurl=ftp:///mydirectory/myrepodir
gpgcheck=0

---
Myrepodir contains all the *.rpm files i need

when i exit and save i get anytime this error

Code:
ftp:///mydirectory/myrepodir/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - ""
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: repobase. Please verify its path and try again

What am i wrong for? How can i just say to my rhel/centos system
"Ehy, for rpm look inside /mydirectory/myrepo" ?

Thanks

Sh: -c: Line 1: Syntax Error Near Unexpected Token `('

Hi,
I am working with a software that is based on Perl scripting and I have encountered with a bash scripting error. So as I am not familiar with bash scripting well, I don't know how I can solve.
sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: ` 32(andRlooks_unw'

It should be mentioned that my $SHELL is /bin/bash. Could you please guide me what '-c' is? where is it? if I change the shebang (the #!/bin/sh part) to #!/bin/bash, the problem will be solved?

Regards,
Zahra

Linux Running MariaDB Database

Hi

I have MariaDB running on Linux. I have created a stored procedu

DELIMITER //
CREATE DEFINER=`root`@`%` PROCEDURE `UpdatePeriodLocaltime`(IN `startUtcTime` datetime, IN `tableName` VARCHAR(50))
BEGIN
DECLARE period, localperiod, startrange, endrange datetime;
declare _offset time;
declare endtime datetime;
declare _dstStart, _dstEnd date;
declare statement varchar(256);


SET period = startUtcTime;

set endtime = addtime(startUtcTime,'1 00:15:00');

select offset, dstStart, dstEnd from timezone into _offset, _dstStart, _dstEnd;

if (startUtcTime >= _dstStart and startUtcTime < _dstEnd) then
set _offset = addtime(_offset, '01:00:00');
end if;


periods_loop : LOOP

IF period >= endtime

THEN leave periods_loop;

END IF;

set localperiod = addtime(period, _offset);
set startrange = addtime(period, '-00:07:30');
set endrange = addtime(period,'00:07:30');


UPDATE updperiod SET timest = period;

set @sql = concat('update ', tableName, ' set periodlocaltime = "', localperiod, '" where starttime > "', startrange, '" and starttime <= "', endrange, '"');

#UPDATE pre_mib2 SET periodlocaltime = addtime(period, _offset) WHERE starttime > (addtime(period, '-00:07:30')) AND starttime <= (addtime(period,'00:07:30'));

prepare stmt1 from @sql;
execute stmt1;
deallocate prepare stmt1;



set period = addtime(period, '00:15:00');


END loop;


END//
DELIMITER ;

But when I try to call the procedure I get the following error:

mysql> call UpdatePeriodLocaltime("2015-04-02","table_name");
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NULL' at line 1


I have created another procedure with only one IN parameter and that works just fine...

What am I missing here?

P