Help with ksh Script not resolving '@' in ls command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with ksh Script not resolving '@' in ls command
# 1  
Old 02-04-2015
Help with ksh Script not resolving '@' in ls command

Hi all,
We've been trying to find a way to get a command to work within a ksh with no success.
We are attempting to list various files with different hlq's like this
Code:
ls $FileDir/dir/subdir/${triggers}

The $FileDir is set in the script.
The $triggers resolves to
Code:
triggers=sys.file@(.test|.uat|.live|).[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].tg

The command works fine from the command line (It returns the list of files) but within the script is says
Code:
sys.file@(.test|.uat|.live|).[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].tg not found.

We suspect the problem is the coding of '@' within the shell as it looks like it is taking the @(.test|.uat|.live|) as a literal name rather than expand it into the three different qualifiers.

Any help much appreciated

Cheers

Last edited by rbatte1; 02-04-2015 at 12:21 PM.. Reason: Added more CODE tags
# 2  
Old 02-04-2015
It always does that to any glob which doesn't match a file, so it's unrelated to @. by itself alone, @ has no special meaning to the shell.

I suspect your script runs using a different shell than your login shell. Either that, or they're running with different options enabled.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 02-04-2015
There may be several reasons for the reported behaviour:
- You are not running the script with a recent bash and thus don't have "extended pattern matching".
- You did not set the extglob option with shopt.
- Your script changed diretory so no files are found.
This User Gave Thanks to RudiC For This Post:
# 4  
Old 02-04-2015
Cheers RudiC I'll look into that
# 5  
Old 02-05-2015
Extended globbing - for example @(...) - is part of ksh93 (you do not need to turn it on), but not ksh88. Could it be that your shell is an older Kornshell or that it is not ksh93 ?

You say it is a script, how are you running the script?

--
@RudiC: It is Kornshell, not bash

Last edited by Scrutinizer; 02-05-2015 at 01:29 AM..
# 6  
Old 02-05-2015
man bash (4.3.30(1)):
Quote:
If the extglob shell option is enabled using the shopt builtin, several extended pattern matching operators are recognized.
# 7  
Old 02-05-2015
Yes But the question is about ksh not bash. Ksh93 also has extended globbing, with even more functionality than bash and it is on by default, there is no shopt function.
This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh script find command not printing any results

Hello, Hitting a wall on this one. When at the command prompt it works fine: # find /home/testuser -name 'PAINT*canvasON.txt' /home/testuser/PAINT_canvasON.txt # pwd /home/testuser # ls -l PAINT*canvasON.txt -rw-r--r-- 1 root user 23 Feb 07 02:58 PAINT_canvasON.txt... (2 Replies)
Discussion started by: seekryts15
2 Replies

2. Shell Programming and Scripting

Help with command in ksh script

I want my script to check directories and files within the directories older than 7days lold and remove them but the script only removes the directories older than 7 days. find home/prod/clt/nal/inb -mtime +7 -exec rm -rf {} \; The inb contains multiple directories that contain... (2 Replies)
Discussion started by: Bperl1967
2 Replies

3. Shell Programming and Scripting

KSH Script to Execute command from specific column in file

Hi Unix Experts,Team I have a file (say comand_file.prm), The file has a command specified in column 6 (say "./execute_script.sh"). I want to execute this command in my script. I am writing a KSH script to achieve this. Could you please assist me with this. (6 Replies)
Discussion started by: Jeevanm
6 Replies

4. Shell Programming and Scripting

AIX .ksh script freezes when using the mail -s command

Hello I am trying to send an email when a .KSH script is run on an AIX Machine. This email will only include a subject line that is made up of variables from within the script, and is as follows: CURRENT_DATE=`date +%Y%m%d` TIME=`date` ADMIN="myname@domain.com" date block () { ... (4 Replies)
Discussion started by: jimbojames
4 Replies

5. UNIX for Advanced & Expert Users

Running ksh script from command line

Hi. I have a ksh script I want to run, but I'm connecting through a telnet and I don't want to FTP the scripts itself. is there a way of running the script from command line ? like ksh "The script itself..." Thanks, Ramon (4 Replies)
Discussion started by: mellowcandle
4 Replies

6. Shell Programming and Scripting

problem with KSH script: command line args

Hi I am executing a KSH script by passing command line arguments example: Red Green Dark Red Blue when I am splitting the arguments by using " "(Space) as delimiter But the colour Dark Red is a single parameter. But it is getting splitted in between How to avoid this. Please help Also... (4 Replies)
Discussion started by: hemanth424
4 Replies

7. Shell Programming and Scripting

KSH script: piping passes command-line arguments

Dear forum I have the following small script: #!/bin/ksh echo -e "abba-o" | awk -F '-' '{ print $2 }' | cut -b 1It needs to be ksh.. in bash I don't have this problem. If I run this on opensuse 10.2 I get this as output: e If I run this on suse enterprise 10 sp2 then I get this: o ... (1 Reply)
Discussion started by: gemtry
1 Replies

8. Shell Programming and Scripting

ssh command in ksh script encounters permission error

I've created a script and copied it to another server and try to execute it at the same time but I'm getting a permission error. I'm logged on as root and I gave the file 777 permission when I created it, but I can't run it remotely via ssh command because of permission issue. Any ideas? ... (5 Replies)
Discussion started by: pdtak
5 Replies

9. Shell Programming and Scripting

Command taken away from ksh script

Hi, Any help or suggestions would be most appreciated. I am having problems in the latter end of this ksh script where I will be checking two files. If they exist do nothing otherwise I need to reinitialize the database which resides on o/s Aix 5.3. The problem I am facing is when the reinit... (2 Replies)
Discussion started by: hgjdv
2 Replies

10. Shell Programming and Scripting

#!/usr/bin/ksh Command Interpreter in a sh script

Hi, I have a developer that is trying to start a script with sh "scriptname". In the script, he is specifying #!/usr/bin/ksh as the command interpreter. For some reason sh is ignoring the #!/usr/bin/ksh. We are running Solaris 8. Does anyone have any ideas what could be causing this? Here... (3 Replies)
Discussion started by: ckeith79
3 Replies
Login or Register to Ask a Question