Commands not working in script file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Commands not working in script file
# 1  
Old 07-15-2010
Bug Commands not working in script file

Hi All,
I have created a shell script having some general copying and moving commands. Commands are working fine in Shell but while executing the shell script it is showing an error
Code:
mv: cannot stat `/apps/orarpt/in/*': No such file or directory

command is
Code:
mv $IN_DIR* $ARCHIVE_DIR

where IN_DIR is like /users/amit/sourcefile/
ARCHIVE_DIR = /users/amit/archive/

on shell when i used these variables with the same value and command
without a single change they are working fine but not in script
so please help me.
Thanks in advance

Last edited by pludi; 07-15-2010 at 01:44 PM.. Reason: code tags, please...
# 2  
Old 07-15-2010
modify the arguments to your move command in this way:
Code:
mv ${IN_DIR}* ${ARCHIVE_DIR}


Last edited by pludi; 07-15-2010 at 01:44 PM..
# 3  
Old 07-15-2010
Code:
IN_DIR is like /users/amit/sourcefile/ 
ARCHIVE_DIR = /users/amit/archive/

What is the script meant to do? Are you trying to move all the files in the directory ${IN_DIR} to the directory ${ARCHIVE_DIR} or something else?

The error message suggests that you are somehow trying to move system directories around.
Be very careful. An "*" is a very powerfile character in shell.

Please post the exact script, mentioning what directory you were in at the time it ran. Is cron involved?
# 4  
Old 07-16-2010
Hi All,
Thanks for your suggestion,
I think i got the solution, its in the assigning of address variables
I should use then like this
IN_DIR=$DESTINATION_DIR"in/"
where DESTINATION_DIR is like /***/***/sync/
and IN_DIR is inside DESTINATION_DIR /***/***/sync/in/
there is no system files there, only flat files and log files are there
Thank you very much
# 5  
Old 07-16-2010
@maindola.amit
It would be advisible to post the proposed script before running the script. We could suggest ways to test the script to display what the script will do without actually moving the files.
# 6  
Old 07-16-2010
Bug

Hi Methyl,
Sorry i didnt get you properly, what you want to say.
See here in this script what i was doing is that i have
to fetch some data from a ftp server and load it into
a local directory and then after processing the files in
local directory i have to move valid files to archive
directory.

Thanks for the suggestion, there are some more issues
i am facing so i would be very thankful to you if you could
suggest me working in right way. i will post them shortly.

Regards,
Amit Maindola
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Tilde commands not working

Hi I have a script that it sends emails to various recipients using mailx, but some of the recipients should be sent as BCC, but ~b flag when used in the following line, does not put the gmail address as BCC: echo "node $output is down" | mailx -s "$output not pinging" sadf@xyz.com ~b... (8 Replies)
Discussion started by: fretagi
8 Replies

2. Shell Programming and Scripting

Sftp commands not working in shell script

hi, i am having 2 linux boxes as source and 1 linux box as destination.i want to create a shell script containing code to transfer a csv file from either of the 2 linux boxes (file will be present in just one box, i need to check both the boxes to see which box has the csv file) to 3rd linux box... (1 Reply)
Discussion started by: linuxlearn2013
1 Replies

3. UNIX and Linux Applications

mplayer snapshot commands not working

About 8-12 months ago I wrote a script that pulled together several mplayer commands to perform various activities. One allowed me to press the s-key to take snapshots with my webcam. Useful for recording the sensors I build. Now it: vd=0 bash-4.1$ TV1="-tv... (2 Replies)
Discussion started by: slak0
2 Replies

4. Shell Programming and Scripting

SED sub commands in KSH not working for me

I am using SED to edit a file (called file) the file contains the word "ERROR" and I want to use SED to: 1. Search for text "ERROR" If found, 2. Append new line with text "hoi" I tried: sed 's/ERROR/ a\hoi' file sed 's/ERROR/ a\ hoi' file I get all the time the error sed:... (7 Replies)
Discussion started by: Alex400
7 Replies

5. Fedora

wall and write commands are not working

hi friends i am using fedora linux operating system on the server and two clients(with windows os) are connected to it(server ).but here wall and write cmds are not working to send messages from one system to another system . pls help me (4 Replies)
Discussion started by: sankar_vitam
4 Replies

6. UNIX for Advanced & Expert Users

commands after .profile modification not working

Hi , I have modified .profile and after that i ran it as .profile. Now no command i working even ls is not working When i type ls , it is showing that -ksh not found I tried to run as . $home/.profile , it is saying as permission denied . How can we do that .. any idea.. Thanks... (2 Replies)
Discussion started by: arunkumar_mca
2 Replies

7. Shell Programming and Scripting

How to get shell commands working through ruby?

Hi all, I am a newbie currently trying to execute shell commands from ruby instead of a shell script.(This method is conceived only for solaris so no issues with porting to other OS and all) Eg: Consider the command 'ls" with a shell script ,I would use it like this bash# ls <all the... (4 Replies)
Discussion started by: wrapster
4 Replies

8. Shell Programming and Scripting

running script in cron - with ssh commands - not working

I ran an ssh command to run a script on a remote server ssh -l <user> <servername> /path/to/script/scriptname This works fine - and the script is executed correctly. However - I put this command into a script, that I want to run from cron every hour, to execute the file on the remote... (31 Replies)
Discussion started by: frustrated1
31 Replies

9. Shell Programming and Scripting

pwd & cd commands not working in shell script

Here is my script #!/bin/bash pwd cd /var/lib/pgsql Both "pwd" and "cd" are not executed is there any other way i can change the current working directory to /var/lib/pgsql pls help! (9 Replies)
Discussion started by: perk_bud
9 Replies

10. UNIX for Dummies Questions & Answers

differnce between working of at and crontab commands

h I would like to know the differnce (both working and how) between at command and crontab.. Thanks in advance Satish D (2 Replies)
Discussion started by: doddas
2 Replies
Login or Register to Ask a Question