LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-12-2010, 09:36 AM   #1
Aubrey0406
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Rep: Reputation: 0
I cannot move a my file into my archives directory in my bash scrip


[asy@backnew auto_cron]$ ./journal_ifms
mv: cannot stat `CUSTOMS*': No such file or directory
standard in must be a tty
 
Old 04-12-2010, 09:40 AM   #2
LouRobytes
Member
 
Registered: Mar 2010
Location: Nova Scotia, Canada
Distribution: Ubuntu & Fedora
Posts: 189

Rep: Reputation: 44
What's the offending command line in your Script?

Lou
 
Old 04-12-2010, 09:42 AM   #3
serafean
Member
 
Registered: Mar 2006
Location: Czech Republic
Distribution: Gentoo, Chakra
Posts: 951
Blog Entries: 14

Rep: Reputation: 135Reputation: 135
Hi, paste the relevant section of your script. At first glance, this seems as though CUSTOMS might be a variable, but you give it to bash as a path...
Also a wildcard ('*') in a filename isn't a good idea.

Serafean
 
Old 04-13-2010, 02:16 AM   #4
Aubrey0406
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Original Poster
Rep: Reputation: 0
mv: cannot stat `CUSTOMS*': No such file or directory standard in must be a tty

su - asy -c /home/asy/auto_cron/test1.sql
customs=CUSTOMS*
mv $customs /home/asy/auto_cron/archives/
cat /home/asy/auto_cron/test1.sql | su - asy sqlplus -s / >/dev/null
cd /home/asy/auto_cron/log
date "+begifms%y%m%d_%H%M" > mydate
TEMPFILE=`grep "$mydate" mydate`
export TEMPFILE
touch ${TEMPFILE}
date "+endifms%y%m%d_%H%M" > mydate
TEMPFILE=`grep "$mydate" mydate`
export TEMPFILE
touch ${TEMPFILE}
rm mydate > /dev/null
 
Old 04-13-2010, 02:42 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,506

Rep: Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890
Please explain what this line in your code is supposed to be doing (according to your thoughts):
Quote:
customs=CUSTOMS*
 
Old 04-13-2010, 03:08 AM   #6
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 2,596

Rep: Reputation: 456Reputation: 456Reputation: 456Reputation: 456Reputation: 456
In a bash script, anything that executes is in a subshell. So, you must make some statement as to where CUSTOMS is, like this:

CUSTOMS=$HOME/customs

Then the subshell executing mv will know where to look.

And for cd you need a CDHOME= line.

Last edited by AwesomeMachine; 04-13-2010 at 03:11 AM.
 
Old 04-13-2010, 05:01 AM   #7
Aubrey0406
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Original Poster
Rep: Reputation: 0
customs=CUSTOMS*

My idea is to make the content of CUSTOMS public / available in order for me to ble to mv it. I have tried export customs and it does not work.
 
Old 04-13-2010, 06:01 AM   #8
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,072

Rep: Reputation: 384Reputation: 384Reputation: 384Reputation: 384
Anything that is set in your script will only work in that subshell (and if exported, maybe, for some childs of that subshell). Exporting a variable doesn't make it usable backwards, in parent shells.

If you want the vars of your script to be dumped literally into your current shell you need to source your script using either the "source" command or a dot.

Code:
$ source my_script.sh
# OR
$ . my_script.sh
# Not to be confused with 
$ ./my_script.sh # or
$ .my_script.sh
However, if you want to make this permanent, you should rather be using ~/.bashrc or whatever initialization file you prefer for your shell of choice.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Move old file to other directory elainelaw Linux - Newbie 1 02-02-2010 02:25 AM
scrip to change directory/file permissions ramesh14 Programming 4 09-11-2008 01:35 PM
Why won't it let me copy or move a file from one directory to another? dewjunkie Linux - Newbie 4 01-23-2008 12:31 AM
how do i get permission to move file into directory timalan SUSE / openSUSE 2 08-24-2005 09:25 PM
Is it possible to move file from /dev to other directory? raindrop Linux - Hardware 2 11-13-2002 05:37 PM


All times are GMT -5. The time now is 09:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration