Is echo $variable >> text.txt working in MacOSX?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Is echo $variable >> text.txt working in MacOSX?
# 1  
Old 11-27-2009
Is echo $variable >> text.txt working in MacOSX?

Hi

New at this, but want to learn more.

I'm trying this as an Shell Command in MacOSX;

Code:
newdate='<TIME>'
echo $newdate >> /Users/ttadmin/Desktop/test.txt

And it don't work. But if I just use;

Code:
echo <TIME> >> /Users/ttadmin/Desktop/test.txt

(<TIME> is an variable that one program uses.)

Hope someone understand the problem..

Best Regards
Thomas
# 2  
Old 11-27-2009
Quote:
Originally Posted by jackt
Is echo $variable >> text.txt working in MacOSX?
Yes, it works fine, but <TIME> is not supported, I don't think. Try date instead.


Code:
newdate=$(date)
echo $newdate >> /Users/ttadmin/Desktop/test.txt

# 3  
Old 11-27-2009
Thanks for quick replay, but that don't work either. Smilie

Code:
newdate='example'
echo $newdate >> /Users/ttadmin/Desktop/test.txt

This for example just give me one blank file (test.txt).

(The <DATE> is an variable that the app I try to use sends out. Other is for example <FILE>, <USER> and so on..)
# 4  
Old 11-27-2009
Quote:
Originally Posted by jackt
Thanks for quick replay, but that don't work either. Smilie
Works fine for me on my Mac Smilie

Code:
apple:/ neo$ 
apple:/ neo$ newdate=$(date)
apple:/ neo$ echo $newdate >> text.txt                       
apple:/ neo$ cat text.txt
Fri Nov 27 17:59:40 ICT 2009
apple:/ neo$

# 5  
Old 11-27-2009
Smilie Smilie

Ok. It works in the Terminal for me to.. Smilie

But not inside the application.. Smilie

The app is the FTP-server Rumpus (one Mac-only app).

(see attached picture)
Is echo $variable &gt;&gt; text.txt working in MacOSX?-picture-2png
# 6  
Old 11-27-2009
Quote:
Originally Posted by jackt
Smilie Smilie

Ok. It works in the Terminal for me to.. Smilie

But not inside the application.. Smilie

The app is the FTP-server Rumpus (one Mac-only app).

(see attached picture)
Of course it does not work. You cannot run Bash terminal commands like this inside an FTP FUI client.

Why did you not mention this in your first post?? Please post all the details in when post a question. Thanks.

Last edited by Neo; 11-27-2009 at 08:27 AM.. Reason: Reopened thread.
# 7  
Old 11-27-2009
I'm sorry, of course should I get you all every info I have..

Backstory: In the FTP-Server (Rumpus) you can use 'Event Notice' that triggers when someone downloads or uploads some files.

And one thing is to use Shell Commands like this (this put the file in a folder that is named after an variable and put some variables in an xml-file in the same folder);

Code:
mkdir /<HOMEPATH ANONYMOUS>/<FORMVAR kund>
echo '<?xml version="1.0" encoding="ISO-8859-1"?>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '<data>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '\t<kund><FORMVAR kund></kund>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '\t<kundmail><FORMVAR kundmail></kundmail>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '\t<projektledare><FORMVAR projektledare></projektledare>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '\t<filename_arg><FILENAME></filename_arg>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '\t<sidor><FORMVAR sidor></sidor>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '\t<date_arg><DATE></date_arg>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '</data>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
cp <FILE> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>
rm <FILE>

This works perfect, but is somehow a bit difficult to overlook and the application don't like this amount of code (to many characters). And I get some input from a friend to use the "$example" to get some better code;

Code:
mkdir /<HOMEPATH ANONYMOUS>/<FORMVAR kund>
outputfile = '/<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml'
echo '<?xml version="1.0" encoding="ISO-8859-1"?>' >> $outputfile
echo '<data>' >> $outputfile
echo '\t<kund><FORMVAR kund></kund>' >> $outputfile
echo '\t<kundmail><FORMVAR kundmail></kundmail>' >> $outputfile
echo '\t<projektledare><FORMVAR projektledare></projektledare>' >> $outputfile
echo '\t<filename_arg><FILENAME></filename_arg>' >> $outputfile
echo '\t<papperkv><FORMVAR papperkv></papperkv>' >> $outputfile
echo '\t<sidor><FORMVAR sidor></sidor>' >> $outputfile
echo '\t<format><FORMVAR format></format>' >> $outputfile
echo '\t<date_arg><DATE></date_arg>' >> $outputfile
echo '\t<time_arg><TIME></time_arg>' >> $outputfile
echo '\t<note><FORMVAR note></note>' >> $outputfile
echo '</data>' >> $outputfile
cp <FILE> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>
rm <FILE>

But this don't work, and it is possible like that Neo is saying that "outputfile = '/<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml'" don't work inside applications (in MacOS X).

So my question this time is:
Is there some other way to solve this? It feels like the app just use direct commands (like the first example).

Thanks Neo for the info, and sorry that I missed all extra info..

Best Regards..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search last column of INPUT.txt in TABLEs text and add correspond columns to INPUT.txt

Hi dears i use bash shell i have INPUT.txt like this number of columns different in one some row have 12 , some 11 columns see last column INPUT.txt CodeGender Age Grade Dialect Session Sentence Start End Length Phonemic Phonetic 63 M 27 BS/BA TEHRANI 3 4 298320 310050... (2 Replies)
Discussion started by: alii
2 Replies

2. Shell Programming and Scripting

Echo command not working in the script

HI I have and echo command which works perfectly in the shell but when i execute in the script it gives me an error code query is as below QUERY=`echo "Select Severity,Dupl_count,Creation_Time,Last_Received,Node_Name,Node_Name,Object,Message_Group,Message_Text,Last_Annotation from " \ ... (2 Replies)
Discussion started by: Jcpratap
2 Replies

3. Shell Programming and Scripting

Echo not working with $

$cat FILE.txt $PATH1/file1.txt $PATH2/file2.txt where$PATH 1 = /root/FILE_DR/file1.txt $PATH 2 = /root/FILE_DR/file2.txt for I in `cat FILE.txt` do v=`echo $I` echo $v if then rm $v (5 Replies)
Discussion started by: ekharvi
5 Replies

4. Windows & DOS: Issues & Discussions

2 Questions: replace text in txt file, add text to end of txt file

so... Lets assume I have a text file. The text file contains multiple "#" symbols. I want to replace all thos "#"s with a STRING using DOS/Batch I want to add a certain TEXT to the end of each line. How can I do this WITHOUT aid of sed, grep or anything linux related ? (1 Reply)
Discussion started by: pasc
1 Replies

5. Shell Programming and Scripting

Echo variable contents into a text file...

Hi all, I am trying to create a script to read my Windows UUIDs and create mounts in fstab. I know there are different and maybe even better ways to mount Windows partitions at boot time, but I always manually create them in fstab successfully. I do a clean install of Ubuntu often and would like to... (2 Replies)
Discussion started by: Ian Pride
2 Replies

6. Shell Programming and Scripting

How to echo $variable into txt file?

Hello i tried many times echo $variables into text file with no success for example: echo "#!/bin/sh BBHTAG=RFOCLT_check # What we put in bb-hosts to trigger this test COLUMN=RFOCLT # Name of the column, often same as tag in bb-hosts $BBHOME/bin/bbhostgrep $BBHTAG | while read... (5 Replies)
Discussion started by: mogabr
5 Replies

7. Shell Programming and Scripting

echo is not working as expected

for i in `cat /export/home/afahmed/Arrvial_time.txt` do echo $i echo $i | awk '$3 < $D { print $4 }' >> dynamic_DF.txt; done When i echo, its echo as Nov 15 02:24 /export/home/pp_adm/inbound//wwallet_20111115.txt where i expect it to be Nov 15 02:24... (7 Replies)
Discussion started by: afahmed
7 Replies

8. Shell Programming and Scripting

Echo working funny

Hello, this is my first post and question. I have search before for this problem but didn't find anything similar. My case: I have a string inside the variable string1 like this: string1="lala lele lili lolo lulu" When I do echo of it, it appears like this: echo $string1 lala lele lili... (8 Replies)
Discussion started by: hemtar
8 Replies

9. Shell Programming and Scripting

echo 2 txt files to screen no carraige return

I have two text files, each of then only containing ONE line and NO carraige return or white space at the end...how do I echo both of these text files to the screen without putting an extra line? I want to do this from the command line. file1.txt: this is file1.txt 1 file2.txt: this is... (4 Replies)
Discussion started by: ajp7701
4 Replies

10. UNIX for Dummies Questions & Answers

echo "ABC" > file1.txt file2.txt file3.txt

Hi Guru's, I need to create 3 files with the contents "ABC" using single command. Iam using: echo "ABC" > file1.txt file2.txt file3.txt the above command is not working. pls help me... With Regards / Ganapati (4 Replies)
Discussion started by: ganapati
4 Replies
Login or Register to Ask a Question