Sponsored Content
Top Forums UNIX for Dummies Questions & Answers ksh script - not getting output from ls Post 302735347 by sudon't on Saturday 24th of November 2012 12:59:35 PM
Old 11-24-2012
-R flag makes no difference

Quote:
Originally Posted by bipinajith
-R option will recursively list sub directories, ls is not listing anything since there are no sub directories to list inside the newly created directory.
Yes, but the newly created directory is itself a sub-directory, so ls -R should show that. And we see in debug mode that it does execute, and outputs the pathname, but the output never makes it to the screen. But I tried it without the -R flag, and it still doesn't work:
Code:
$ ./newdir.ksh
Name a directory that ought to exist: Fun/Super/Duper/Pooper
Directory does not yet exist. I will make it so...
$

Now, I can use the -v flag in mkdir, but the mkdir man page suggests:
Quote:
The -v option is non-standard and its use in scripts is not recommended.
But, ok, it's not like my little exercise is gonna end up on another system. Nevertheless, I would like to know what I'm doing wrong - that is, why ls works in the second instance, (if the dir already exists), but not the first, (if it has to create the dir).

---------- Post updated at 12:59 PM ---------- Previous update was at 12:47 PM ----------

Quote:
Originally Posted by in2nix4life
I copied your script and it ran fine. What OS?

Code:
ksh -x newdir.ksh 
+ print -n 'Name a directory that ought to exist: '
Name a directory that ought to exist: + read dir
testdir
+ [[ ! -d /home/testuser/testdir ]]
+ print 'That directory does exist, as well it should.'
That directory does exist, as well it should.
+ ls -R /home/testuser/testdir
/home/testuser/testdir:

Yes, it works when the directory already exists, but not when it has to create the directory. Try using it to create a new directory and see if it works for you.

Mac OS 10.6.8
ksh 93

Last edited by sudon't; 11-24-2012 at 02:30 PM.. Reason: clarity
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies

2. Shell Programming and Scripting

ksh: cmd output to input of another script

I want to write a script in KSH that takes the output of one command and redisplays it. Something like: while true do read inpt date +"%I:%M:%S %p <-> $inpt" done and then some how get the output of the ping command to redirect to the input of this script. does that make sense? (2 Replies)
Discussion started by: IMTheNachoMan
2 Replies

3. Shell Programming and Scripting

ksh script that echo " please insert your name " and store the output to a login.log file.

Hello All Nice to meet you all here in this forum, it's my 1rst time here i'm asking about a little issue that i face i added a ksh script that echo " please insert your name " and store the output to a login.log file. the script is working fine with normal telnet but Xstart is not working... (8 Replies)
Discussion started by: islam.said
8 Replies

4. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

5. Shell Programming and Scripting

ksh script to process grep output

Hi, I would like to know how can i pipe the following output of grep into a predefined output format This is the output of the grep command grep record *.txt | sort -r 2010-04-28-11-12-21.txt:C The user has created a record 2010-04-29-10-18-41.txt:U The user has updated a record... (8 Replies)
Discussion started by: alienated
8 Replies

6. Shell Programming and Scripting

Help with ksh script to display output with specific contents

This is Input - starts with Storage Group Name and ends with Shareable and the loop continues all I need is Storage group name and Alu numbers in the below output format requested. Storage Group Name: abcd Storage Group UID: 00:00:000:00:0:0:0 HBA/SP Pairs: HBA UID ... (6 Replies)
Discussion started by: maddysa
6 Replies

7. Shell Programming and Scripting

Output in for loop (ksh)

Hi , I'm writing the for loop script in home directory and wanted to get the files from /etc/data directory. #!/bin/ksh file_nm="/etc/dat" for test_data in $file_nm/fln* do echo "$test_data" done the code is executing successfully , but in the output it is showing ... (6 Replies)
Discussion started by: smile689
6 Replies

8. UNIX for Dummies Questions & Answers

Executing ksh script to remote server want output on same window

I'm having a brain freeze moment. I've created a ksh script in AIX that ssh's to a remote server, executes some commands, and then logs out. All of this is sent to a file. I then have the script cat the file so i can see the output. Even though the cat command is outside of the remote session part;... (5 Replies)
Discussion started by: seekryts15
5 Replies

9. Shell Programming and Scripting

Line break in sqlplus output through ksh script

Hi, I am new to shell script programming. I have written a ksh script to run the sql File placed in server directory and spool the output in destination directory. Below Command: $ORACLE_HOME/bin/sqlplus -s $ora_uid @$sqlfile_loc$testquery.sql > $opfiledirectory It is generating the output... (6 Replies)
Discussion started by: Sumit Arora
6 Replies

10. UNIX for Beginners Questions & Answers

Passing output parameter(Oracle) to variable in ksh Script

Hello, I have researched and tried many way to pass OUT parameter to be stored in variable in KSH Script.Still not success, please help. Here is my Store Procedure. create procedure testout3(v_in varchar2,v_out OUT integer) as begin v_out := 1; end; Here is my testvout.ksh #!/bin/ksh... (1 Reply)
Discussion started by: palita2601
1 Replies
All times are GMT -4. The time now is 02:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy