Who can finish this script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Who can finish this script?
# 8  
Old 09-10-2013
The output you have shown looks good. The mv statement is trying to move 4 files each to the 6 directories.

Now you may remove the "echo" before mv statement and run the script to actually move the files.

I have tested this for number of files not being exact multiple of 6 as well and it worked.
# 9  
Old 09-10-2013
aha, yes I see the result on the monitor and it seems good, but nothing moved.
I understand you now when you said remove echo after verified.

Done.
The result is great.
Thanks a lot Mr. krishmaths

---------- Post updated at 05:25 AM ---------- Previous update was at 02:38 AM ----------

Another point please.
After this distribution process is done, there are some services is down, don't worry about that.
Now I wrote a small script called (jjjjj.sh) to check if the process is up, if no the script will up it.

Note:
rating = the name of the user who own the service.

PRE_VOICE_O_2 = the service name which I look for it.

The long line in the script, don't worry about it, just check the first 2 lines.

Code:
 
ps -fu rating |grep -E "PRE_VOICE_O_2" | grep -v grep | awk '{print $2}' | wc -l | read PRE_VOICE
if [ PRE_VOICE -le 1 ]
then
nohup /bossapp1/rating/bin/ratprecdr PRE_VOICE_O_2 1 1 1 0 97 106 1 >>~/log/precdr/prevoice2.out &
fi

Now, when I run it, this error is appearing:
./jjjjj.sh: line 2: [: PRE_VOICE: integer expression expected
# 10  
Old 09-10-2013
Looks like you missed a $ to refer the variable.

Code:
if [ $PRE_VOICE -le 1 ]

# 11  
Old 09-10-2013
Thanks dear.
The problem was a tiny note:
Thr word (rating) which is the user name, I must write it in a separate line as the following: user=rating
then in all lines I must write:
Code:
 
ps -fu $user |grep -E "PRE_VOICE_O_2" | grep -v grep | awk '{print $2}' | wc -l | read PRE_VOICE

another note, I must write the line: #!/usr/bin/ksh in the beginning
# 12  
Old 09-10-2013
Quote:
Originally Posted by Mohannad
Another point please.
In the future, when the follow up is unrelated to the thread's topic, start a new thread.

Regards,
Alister
This User Gave Thanks to alister For This Post:
# 13  
Old 09-10-2013
Quote:
Originally Posted by alister
In the future, when the follow up is unrelated to the thread's topic, start a new thread.

Regards,
Alister
Yes, right.
Sorry for that Alister
# 14  
Old 09-10-2013
If you don't have any preference which file goes where, you could try
Code:
mkdir tmpdir
DIRS=( $(ls -d S*) )
FILES=( $(ls tmpdir/*) )
CNT=$((${#FILES[@]} / ${#DIRS[@]}))
for D in ${DIRS[@]}; do for ((i=0; i<=$CNT; i++)); do echo mv ${FILES[ST++]} $D; done; done
rmdir tmpdir

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finish current script and execute next script

Hi, I've come accross a situation where I need to exit from current shell script at the same time I need to start/activate another shell script. How can I do that in KSH ?? Need help !! For example, my script is as below #!/bin/ksh paramFile="/home/someXfile.lst" ] && <<Here I... (1 Reply)
Discussion started by: R0H0N
1 Replies

2. Shell Programming and Scripting

Cannot execute/finish script because of last line syntax error: unexpected end of file/token `done'

first of all I thought the argument DONE is necessary for all scripts that have or begin with do statements which I have on my script, However, I still don't completely understand why I am receiving an error I tried adding another done argument statement but didn't do any good. I appreciate... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

3. Shell Programming and Scripting

expect ssh script cannot finish and exit

All i am new to linux, and try to have a simple expect script to ssh then telnet to the network equipment, and exit itself. but dont know why i hang at the last $ #!/usr/bin/expect set timeout 10 set arg set arg1 spawn ssh -l UserA 1.1.1.1 expect "assword:"; send "PasSwOrD\r";... (1 Reply)
Discussion started by: samoptimus
1 Replies

4. Shell Programming and Scripting

Please help me to finish this scripts

Hi All, Can anyone help me to finish the scripts. this scripts is this scripts will run on crontab in every 4 minutes to get the newest router interface status. I would like to add a function to count the router interface flapping, if more than 2 times in 20 minutes (scripts run 5 times)... (1 Reply)
Discussion started by: momo0617
1 Replies

5. Shell Programming and Scripting

finish of file

Hello, I'm doing a script where I'm traveling a file, and moves down line by line, and is copied to another file, up to the line 100, then the smaller file passes to another format ... but the problem I have is that if there are 357 lines for example, file 1 2 i 3, converted correctly but the 4... (1 Reply)
Discussion started by: uri_crack
1 Replies

6. Shell Programming and Scripting

Finish script help

I am trying to add a finish script that can copy hosts, static routes and a few other files into relevant directories on a client system. These files would be mounted as nfs resource on the client as hosts.hostname, static_route.hostname etc. Script will compare the hostname of the client and copy... (0 Replies)
Discussion started by: c0kazaz
0 Replies

7. UNIX for Dummies Questions & Answers

Jumpstart finish script (Solaris 10)

Hi there, I wanted to write a finish script for my jumpstart server which creates a ntp.conf file and enables ntp on the client machines during installation. Is that possible? Thanks for the help :) P.S. I'm a real Solaris noob, so do excuse me if I sound like an idiot..lol (1 Reply)
Discussion started by: iman453
1 Replies

8. UNIX for Advanced & Expert Users

commands do not finish

Hi, I have strange problem executing some command on solaris 5.9 ps command does not finish(hangs) and runs forever without any result. same with cc command too.Please suggest (1 Reply)
Discussion started by: Raom
1 Replies

9. UNIX for Dummies Questions & Answers

how do i finish this last one..

i tried to build a command to replaces the word "include" with "exclude" in each *.h type of file in a certain directory and to display the lines in which the switch happened. i did a command and i dont know why its not working find /usr -name "*.h" -exec sed 's/include/exclude/g' {} \;... (2 Replies)
Discussion started by: newby2
2 Replies

10. Shell Programming and Scripting

How to check succeesfull finish of a executable from the sheel script

Hi, I want to know is there a way out wherein we can know that the C++ executable has finished its task. Following is the steps: 1.Shell script calls a executable after setting all the env variables. 2.Now after the executable has done its job(basically to create some outpur files).The... (2 Replies)
Discussion started by: electroon
2 Replies
Login or Register to Ask a Question