LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 03-10-2014, 10:47 AM   #1
tqz
Member
 
Registered: Jan 2008
Posts: 67

Rep: Reputation: 15
Variable not passing to file in bash script


Hello All

I store a variable after being read using the echo command so something like:-

VOLUME=$(echo command to read name of volume)
echo $VOLUME

I then write this name in a command list file a bit later in the script, so something like:-

echo $string5 >> command_list_file

When running this file from the command line the name of the file gets inserted into the command_list_file. However, when running the file via a cron job, the name of the file doesnt???

Any idea why this may be?

Thanks in advance to any help!
 
Old 03-10-2014, 10:49 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Where you have:

Code:
VOLUME=$(echo command to read name of volume)
ensure you have the /full/path/to/the/command
 
Old 03-10-2014, 12:11 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Above is good advice, but the general question you have asked is very difficult to assist with if you have provided no actual details.
 
Old 03-11-2014, 04:39 AM   #4
tqz
Member
 
Registered: Jan 2008
Posts: 67

Original Poster
Rep: Reputation: 15
TenTenths - I think you are correct! Have edited the script and added the full path. Will find out later on today if it works! If so, thank you very much - especially as I realised after re-reading my post that it was full of errors! Will update later !
 
  


Reply



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
[SOLVED] Passing variable from bash script to php script. Dafydd Programming 5 11-29-2013 11:53 PM
[SOLVED] passing variable through script (bash) ted_chou12 Programming 1 11-20-2011 10:17 AM
passing variable from bash to perl in a bash script quadmore Programming 6 02-21-2011 04:11 AM
passing array and variable to function in bash script ajaypitroda Programming 2 07-07-2009 11:10 PM
Bash Script Passing variable to Function nutthick Programming 2 02-02-2005 05:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:27 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
Open Source Consulting | Domain Registration