maybe?
if its possible? i got one sourcedir with all .xml files on my localhost and i have upload all files to server:/basedir/filenamefolder/filename.xml
---------- Post updated at 02:54 PM ---------- Previous update was at 02:51 PM ----------
but on ls he maybe will pickup the .xml too?
---------- Post updated at 03:47 PM ---------- Previous update was at 02:54 PM ----------
also something like that but only working xD
echo Enter your local directory
read localdir
for FILE in $(ls -1 | cut -d. -f1 "$localdir"); do scp $localdir/$FILE.xml user@server:/path/$FILE/$FILE.xml
@vgersh99 nope that didnt work cause i need the file name for the fully remoteDirpath
$(ls -1 | cut -d. -f1 "$localdir")
---------- Post updated at 07:00 PM ---------- Previous update was at 04:56 PM ----------
ok i got it
for FILE in $(ls -1 "$localdir" | cut -d. -f1 | grep -E '^[A*]'); do scp $localdir$FILE.xml $user@servername:$FILE/$FILE.xml; done
---------- Post updated at 07:19 PM ---------- Previous update was at 07:00 PM ----------
Ok next question xD
if check_file test.sh; then
echo "File exists"
else
echo "
#!/bin/bash
SOURCEDIR=${manifest}
if [ -z "$STY" ]; then exec screen -dm -S 'test Import' /bin/bash "$0"; fi
for i in *; do id=$(echo ${i} | cut -d'_' -f1 | cut -c 2- ); extid=00${id}; /root/test_dir/other_test_file.pl -b ${SOURCEDIR} -m ${extid} -v 2>&1 | tee /root/test_dir/${extid}.log ; done " >> test.sh
echo created test-Importer
fi
i want to write this file
but i only want to fill this Varible on the script
SOURCEDIR=${manifest}
the other variables i want to fill later if i running the new created file on server
but if i use this all Variables been removed after creating file
and it looks like that
#!/bin/bash
SOURCEDIR=/mnt/f/test5/
if [ -z ]; then exec screen -dm -S 'test Import' /bin/bash ./menu.sh; fi
for i in *; do id=; extid=00; /root/test_import/other_test_file.pl -b -m -v 2>&1 | tee /root/test_import/.log ; done
but i need it like that
#!/bin/bash
SOURCEDIR=/mnt/f/test5/
if [ -z "$STY" ]; then exec screen -dm -S 'test Import' /bin/bash "$0"; fi
for i in *; do id=$(echo ${i} | cut -d'_' -f1 | cut -c 2- ); extid=00${id}; /root/test_dir/other_test_file.pl -b ${SOURCEDIR} -m ${extid} -v 2>&1 | tee /root/test_dir/${extid}.log ; done " >> test.sh
echo created test-Importer
fi
A little background: "${...}" is not just any string for the shell but a sort-of command: it means to replace the string ${...} with the value assigned to the variable named ... . If there was nothing assigned before this value is "" (the empty string).
If you want the shell to interpret any character or string literally instead of using the aforementioned interpretation on it there are two ways: quoting and escaping. Quoting means to surround a string by double or single quotes. double quotes only turn off some interpretation mechanisms (i.e. field splitting), but single quoting turns off all of them, also the "variable expansion". Try this to see the difference ( wc counts the number of words) :
The other mechanism is escaping: by prepending a character with a backslash you can remove its meaning for the shell and turn it back into an ordinary character. Try this and notice the difference:
x="abc 123"
echo ${x}
echo \${x}
In your case it could look like this (notice that i use ksh syntax here). Btw., i have straightened out your code, because you don't want such lines not eve in your generated code, much less in your source. Such long lines are hard to read. As a rule of thumb: no line should be longer than 80 characters.
Another thing is: you used echo "..." >> test.sh . This would append the content rather than create a new file when the script runs. I changed that to create/overwrite the file. change the first exec-statement if i assumed wrongly:
Another observation: the command exec screen -d... will leave the script because exec replaces the running process (here the script) with the newly called one (here the screen command. Is this intentional?