Does this statement of code mean.....


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Does this statement of code mean.....
# 1  
Old 01-12-2011
Does this statement of code mean.....

Good morning,
I am 100% mew to Unix and am trying to troubleshoot why a pgm written 3 years ago, suddenly is not working properly. It is part Perl with some UNIX commands thrown in. I need to verify what the UNIX commands are doing before I can continue with my other troubleshooting.

Code:
print "<pre>";
print system("cat tmp\\*.log | c:\\wbin\\sort.exe -k 3 -r");
print "</pre>";

After searching for a few days I was able to determine the above is referencing UNIX. This is what I think is going on - and am looking for verification of this PLEASE!!

Moving all material from the tmp folder with the extension of .log into the UNIX sort pgm and performing the sort function. The sort pgm is being called using the new style of sorting (-k) in reverse order (-r) and sorting on the 3rd field in the files.

Can someone verify that for me???

Thank you for any and all your time with helping me to understand this short piece of code.

Amy
# 2  
Old 01-12-2011
Code:
cat tmp\\*.log | c:\\wbin\\sort.exe -k 3 -r

Its combining all the tmp log files and the output of them is sorted by the 3rd column in reverse order.
Smilie good luck with dis
# 3  
Old 01-14-2011
OK....I understand what this is doing - BUT I have an error that is preventing this execute fully. The error message is: cat' is not recognized as an internal or external command, operable program or batch file.

I have the cat.exe application stored in two areas on the server - within the c:\WindowsSystem32 folder and also in the c:\wbin folder. Is there anywhere else this should be moved/copied to? Is there another piece I am missing to have cat recognized and run successfully? I have also added the cat.exe application to the system32 folder on the local machine that is trying to run the script and that did not resolve the issue either.

Thanks in advance!!
# 4  
Old 01-14-2011
Code:
c:\\wbin\\cat.exe tmp\\*.log | c:\\wbin\\sort.exe -k 3 -r

# 5  
Old 01-14-2011
Tools Suddenly not working...

A few guesses:
- different person (user) running
- a change to the PATH command (PATH is where the system look for programs not resident in current directory)
- change to user permissions and/or file & directory rights not allowing you to find the CAT program
# 6  
Old 01-16-2011
Command not found

Amy,

You will get the same error if you go to command prompt and try to execute anything that doesn't exist. For example, go to C:\ and type "Hello", you will get the same error.

This is a matter of Windows not being able to find the cat command. Resolve that, and the code will run.

Joeyg had a good suggestion, if it's not in the PATH suddenly, it won't be automagically found. If this is a new concept for you I suggest reading on general operating system concepts.
# 7  
Old 01-21-2011
Thank you for all the assistance! Once I added the PATH info it works great! I do have one more question now that I have gotten back to working on this. If I wanted this to put the combined sorted info into a text file, is this the correct format? I am not getting any data in the file and this is why I would like to ask.

Code:
c:\\wbin\\cat.exe tmp\\*.log | c:\\wbin\\sort.exe -k 3 -r > c:\\TLlogs.txt

Error Message: c:\\wbin\\cat.exe: write error: Invalid argument

Thank again for all the help with my adding the PATH location info correctly - and for any assistance with this one!!

Last edited by jaacmmason; 01-21-2011 at 12:32 PM.. Reason: added error message
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Error code with if statement

hello all im new to unix and when i use below script i get an error : #! /bin/bash Echo -e "enter the name of the file : \c" read file_name if then echo "$file_name found" else echo "$file_name not found" fi running the script i get below error : $ ./hello (26 Replies)
Discussion started by: Ibrahims1
26 Replies

2. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

3. Shell Programming and Scripting

Statement

${PFILE}.backupfile Please tell me what the above statement means? (1 Reply)
Discussion started by: lg123
1 Replies

4. UNIX for Dummies Questions & Answers

How to use a return code in an if statement?

Hi all, After so many tries and searching online for ideas, I had trouble accomplishing this. Is it possible to do something like this in KSH to run an if statement on a return code? Unfortunately the code below fails... Would anyone know how to fix the below attempt? if "$`{pkginfo... (3 Replies)
Discussion started by: chatguy
3 Replies

5. UNIX for Dummies Questions & Answers

if statement code syntax

Hi, can someone please tell me what is wrong with this code? I just want it to check if the file size is greater than 2000kb. if Thanks! ---------- Post updated at 09:23 PM ---------- Previous update was at 09:21 PM ---------- I should probably post the full code: #!/bin/sh... (9 Replies)
Discussion started by: Bengel
9 Replies

6. UNIX for Dummies Questions & Answers

for statement

removed the link due to some issues and i got the information i needed (4 Replies)
Discussion started by: Amit Sura
4 Replies

7. Shell Programming and Scripting

How is use sselect statement o/p in insert statement.

Hi All, I am using Unix ksh script. I need to insert values to a table using the o/p from a slelect statement. Can anybody Help! My script looks like tihs. ---`sqlplus -s username/password@SID << EOF set heading off set feedback off set pages 0 insert into ${TB_NAME}_D... (2 Replies)
Discussion started by: nkosaraju
2 Replies

8. Shell Programming and Scripting

If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands. How do I write the "do nothing" statement in the following example? Example: if (( "$x"="1" && "$y"="a" && "$z"="happy" )) then do nothing else command command fi... (3 Replies)
Discussion started by: april
3 Replies

9. Programming

What does this statement mean?

If I declare a structure as: typedef struct { int id; void* ptr; int size; } kpage_t; And then use this to do some initialization... *((kpage_t**)page->ptr) = page; What exactly is being done? I have some trouble with pointers here... :( And if there's a macro... (1 Reply)
Discussion started by: Legend986
1 Replies

10. Shell Programming and Scripting

Code checking for all values in the same if statement.

I am trying to set up a variable based on the name of the file. function script_name { if then job_name='MONITOR' return job_name; elsif then job_name='VERSION' return job_name fi } for i in `ls *log` do script_name $i done. (4 Replies)
Discussion started by: oracle8
4 Replies
Login or Register to Ask a Question