/bin/bash to write a form letter [solved]
Ok, in principal, I need to have bash read in a file and make substitutions for variables I have defined in a skeleton file. Kind of like a form letter. Why? I have torque installed on my machine and I need to have my repo-ck build script make a custom build.sh that each respective cluster job will call.
I'm no student and this isn't homework. Anyway, here is an oversimplified example
letter.skl:
Dear $name,
The party starts at $time.
Regards,
$me
So the bash script defines all three of those variables and needs to read in the letter.skl and pipe it into a new file that contains the "final" output. How can this be accomplished?
#!/bin/bash
name="John"
time="11 o'clock"
me="graysky"
Last edited by graysky (2011-06-18 22:38:33)
Yeah... this is how I'm doing it now, but it's very clunky. I need to generate within my build.functions two files:
1) A build script unique to each arch and cpu package
2) A queue file for the cluster that will call #1
I have leveraged the echo method as I said, but its not elegant and very ugly. What would be far better would be for me to have a skeleton script I can read in, substitute and write out if this is possible natively in bash.
Example of my "ugly" code:
# make cluster.pbs
echo "#!/bin/bash" > $pkgarch-$arch.pbs
echo "#PBS -l nodes=1,walltime=1:00:00" >> $pkgarch-$arch.pbs
echo "#PBS -N $arch-$pkgarch" >> $pkgarch-$arch.pbs
echo " " >> $pkgarch-$arch.pbs
echo "[[ $arch = \"x86_64\" ]] && $workdir/build-$pkgarch-$arch.sh" >> $pkgarch-$arch.pbs
echo "[[ $arch = \"i686\" ]] && sudo linux32 chroot /opt/arch32 /bin/bash -c $workdir/build-$pkgarch-$arch.sh ; sleep 1s" >> $pkgarch-$arch.pbs
# make script it needs if building in chroot
echo "#!/bin/bash" > $workdir/build-$pkgarch-$arch.sh
echo ". /home/$me/.credentials" >> $workdir/build-$pkgarch-$arch.sh
echo "cd $workdir" >> $workdir/build-$pkgarch-$arch.sh
echo "whatarch=\$(uname -m)" >> $workdir/build-$pkgarch-$arch.sh
echo "if [ \$whatarch = \"x86_64\" ]; then" >> $workdir/build-$pkgarch-$arch.sh
echo " makepkg -g >> PKGBUILD && makepkg -sc" >> $workdir/build-$pkgarch-$arch.sh
echo "else" >> $workdir/build-$pkgarch-$arch.sh
echo "su -c \"makepkg -g >> PKGBUILD && makepkg -sc\" $me" >> $workdir/build-$pkgarch-$arch.sh
echo "fi" >> $workdir/build-$pkgarch-$arch.sh
echo " " >> $workdir/build-$pkgarch-$arch.sh
echo "for i in PKGBUILD \"\$_config\"; do" >> $workdir/build-$pkgarch-$arch.sh
echo "mv \$i $des_cluster/repo/$arch/files/\$i.$pkgarch" >> $workdir/build-$pkgarch-$arch.sh
echo "done" >> $workdir/build-$pkgarch-$arch.sh
echo " " >> $workdir/build-$pkgarch-$arch.sh
echo "x=0" >> $workdir/build-$pkgarch-$arch.sh
echo "for i in \$(ls *.xz); do" >> $workdir/build-$pkgarch-$arch.sh
echo " array[\$x]=\$i" >> $workdir/build-$pkgarch-$arch.sh
echo " x=\$(( \$x +1 ))" >> $workdir/build-$pkgarch-$arch.sh
echo " mv \$i $des_cluster/repo/$arch" >> $workdir/build-$pkgarch-$arch.sh
echo "done" >> $workdir/build-$pkgarch-$arch.sh
echo " " >> $workdir/build-$pkgarch-$arch.sh
echo "files=\$(echo \${array[@]}|sed s'/\ /,/')" >> $workdir/build-$pkgarch-$arch.sh
echo "if [ \$whatarch = \"x86_64\" ]; then" >> $workdir/build-$pkgarch-$arch.sh
echo " curl -u \$myusername:\$mypasswd -T $des_cluster/repo/$arch/{\$files} ftp://\$mysite/\$arch/ -s &" >> $workdir/build-$pkgarch-$arch.sh
echo "else" >> $workdir/build-$pkgarch-$arch.sh
echo " su -c \"curl -u \$myusername:\$mypasswd -T $des_cluster/repo/$arch/{\$files} ftp://\$mysite/\$arch/ -s & $me" >> $workdir/build-$pkgarch-$arch.sh
echo "fi" >> $workdir/build-$pkgarch-$arch.sh
chmod +x $workdir/build-$pkgarch-$arch.sh
qsub $pkgarch-$arch.pbs > /dev/null
Similar Messages
-
Hello all.
I've just installed arch, despite very little knowledge of linux (i had ubuntu for a short while before this), but I like a challenge so i thought i'd throw myself in at the deep end.
The installation went reasonably smoothly, but now i've got it up and running (with a minimal KDE install) but when I open up the konsole, I get the message
"Warning: Could not find '/bin/bash/', starting '/bin/sh' instead. Please check your profile settings."
and subsequently I cannot "su jake" (jake being my username, obviously). It requests my password, but when i press return I get the response
su: /bin/bash/: Not a directory
which means i've obviously done something wrong, but I cant make head nor tail of the archwiki on Bash, and from googling, I cant find anyone with a similar issue. I can run from root, but it's not ideal.
Thanks for any response as to why this might be happening, and how to fix it.
Last edited by hansolo128 (2012-04-24 08:55:37)@oxyd
sh-4.2$ cat /etc/shells
# /etc/shells
/bin/sh
/bin/bash
# End of file
root:x:0:0:root:/root:/bin/bash
jake:x:1000:100::/home/jake:/bin/bash/
the output of /etc/passwd is
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/bin/false
daemon:x:2:2:daemon:/sbin:/bin/false
mail:x:8:12:mail:/var/spool/mail:/bin/false
ftp:x:14:11:ftp:/srv/ftp:/bin/false
http:x:33:33:http:/srv/http:/bin/false
nobody:x:99:99:nobody:/:/bin/false
dbus:x:81:81:System message bus:/:/bin/false
jake:x:1000:100::/home/jake:/bin/bash/
usbmux:x:140:140:usbmux user:/:/sbin/nologin
mysql:x:89:89::/var/lib/mysql:/bin/false
kdm:x:135:135::/var/lib/kdm:/bin/false
avahi:x:84:84:avahi:/:/bin/false
moving my home directory from /bin/bash/ to /bin/bash on the line of my username now allows me to su jake, but it doesnt solve the warning that /bin/bash/ doesnt exist. -
[solved] ssh will only login to /bin/bash
I have a machine with a few users and an ssh server.
I would like to setup a user with rbash or nologin for the shell but if i do that, I can't ssh onto that user.
my /etc/passwd
zidar:x:1000:100:zidar:/home/zidar:/bin/bash
smotko:x:1001:1001::/home/smotko:/bin/rbash
now
ssh zidar@pc
su smotko #this works
# but this doesnt
ssh smotko@pc # works only if i change the passwd file back to /bin/bash
this is with my log for ssh with rbash
Dec 25 03:17:25 arch-dev sshd[636]: Failed password for smotko from 10.0.2.2 port 49075 ssh2
and same with bash
Dec 25 03:20:18 arch-dev sshd[678]: Accepted password for smotko from 10.0.2.2 port 49088 ssh2
and this is how ssh looks with anything other than /bin/bash in /etc/passwd
$ ssh smotko
smotko@pc's password:
Permission denied, please try again.
password is correct because i can use it locally
thank you for helping
Last edited by zidarsk8 (2014-03-14 14:59:17)The Arch bash package doesn't actually have the /usr/bin/rbash command. So not only is this not included in the /etc/shells file, but you are also trying to set the shell to something that doesn't actually exist. See the RESTRICTED SHELL section of the bash man page.
I think wat you are after might be achieveable by simply using 'set' in the given user's startup files. -
[solved]Terminator can not start /bin/bash
Terminator show an error:
Unable to start shell:/bin/bash
this error comes from here:
/usr/lib/python2.7/site-packages/terminatorlib/terminal.py
1292 self.pid = self.vte.fork_command(command=shell, argv=args, envv=envv,
1293 loglastlog=login,
1294 logwtmp=update_records,
1295 logutmp=update_records,
1296 directory=self.cwd)
1297 self.command = shell
1298
1299 self.titlebar.update()
1300
1301 if self.pid == -1:
1302 self.vte.feed(_('Unable to start shell:') + shell)
1303 return(-1)
But I can startup terminator using root acount
the self.pid != -1 when I'm root
I dont remeber change any privileges ...
Any idears ?
Last edited by Hacksign (2013-08-27 01:47:33)Scimmia wrote:is /dev/pts listed in /etc/fstab? If so, remove it.
Thanks, that's actually resolved my problem -
[SOLVED] Terminator stopped working Unable to start shell:/bin/bash
Hello,
I just wanted to share as I didn't found anything about it,
Since yesterday I can't launch my favorite terminal emulator which is terminator, it gives me :
Unable to start shell:/bin/bash
displayed in terminator window where I'm supposed to type commands.
What is strange is that I can launch /bin/bash in tty's plus I installed xterm temporarily which works fine with bash.
One more thing is that if I close terminator window it closes my graphical session !
Any idea to troubleshoot this ?
Last edited by detestable (2013-08-16 08:39:54)I'm getting this :
me@latitude ~ $ gdb /usr/bin/python
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/python3.3...(no debugging symbols found)...done.
(gdb) run /bin/terminator
Starting program: /usr/bin/python3.3 /bin/terminator
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
File "/bin/terminator", line 103
except (KeyError,ValueError), ex:
^
SyntaxError: invalid syntax
[Inferior 1 (process 13780) exited with code 01]
I also tried gnome-terminal which is not working correctly (installed right now)
From the user interface it says in red :
"There was an error creating the child process for this terminal"
"grantpt failed: Operation not permitted"
From gdb :
m@latitude ~ $ gdb /usr/bin/gnome-terminal
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/gnome-terminal...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/bin/gnome-terminal
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffea2b9700 (LWP 13839)]
Error: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._vte_2dpty_2derror.Code1: grantpt failed: Operation not permitted
[Thread 0x7fffea2b9700 (LWP 13839) exited]
[Inferior 1 (process 13835) exited normally]
Only xterm seems to work -
[SOLVED] /bin/bash not running
Hi!
I upgraded the system as usual (pacman -Syy) and now (I've rebooted a few times) neither konsole or terminator or any other terminal, just the Ctrl+Alt+FX ones
Konsole just keeps being a black window while Terminator says that it was imposible to execute /bin/bash
I don't have any idea what could have happenned. Any idea? Which log stores the problems of /bin/bash?
Thanks
Last edited by eherranzr (2013-08-20 13:51:59)karol wrote:
https://mailman.archlinux.org/pipermail … 33999.html ?
Edit: pacman -Syy doesn't upgrade your system ...
Thanks, I don't understand why this changed this way and why I haven't seen it enywhere
Sorry, a typing error, meant -Syu -
I get error when I run Terminal /bin/bash: Please run this as root.
Help!
Every time I open Terminal I get:
/bin/bash: Please run this as root.
[Process completed]
Any suggestions?FLYFI5H wrote:
Help!
Every time I open Terminal I get:
/bin/bash: Please run this as root.
[Process completed]
Any suggestions?
I wonder if there's a permissions problem with your /bin/bash. If you go to the /bin directory (presumably with the Finder's Go -> Go to Folder command, as Terminal isn't working for you), then do a "Get Info" on bash, what do you see as the permissions? Mine shows "system: Read & Write", "wheel: Read only", and "everyone: Read only".
If you can't run Terminal, your diagnostic options may be limited. Do you have a second Mac that you could use to investigate the problem with this Mac in "target disk mode"? -
How to write an open letter to nokia CEO?
hi,
i am really frustrated with nokia CC and complaint department. i want to write an open letter to your CEO. how to write an open letter and what should i mention in that letter?
Thanks in advance,
regards,
former staunch supporter now a frustrated user of nokia lumia devicehi adrianhughes,
thanks for reply.
thing is nokia cc and complaint dept both are saying the same thing "we are waiting for an update from nokia back end team"
my question is "how much time they need to decide with which device they can replace my mobile?"
going to consumer forum is not a practical solution in india btw.
regards, -
How to use /bin/bash in my "request" script inside software packaging
Hi,
I know that the "request" script in packaging is run with /bin/sh. Is it possible to run this script with /bin/bash to be able to use more complex and helpful scripting ?
I tried by adding #!/bin/bash in the script by I think this is disregarded by the install process.
Thanks,
BiancaOh, so THAT's how it works... Thanks for your help! I was expecting to have them displayed before to submit the form and, most important, once the "reqldap" has finished to process the data, as some kind of callback function.
I would like to be sure the different request doesn't prevent eachother to be processed correctly...There is no apparent reason why I can only make one request to that specific file on the server. All the next call to it will just be ignored when opening the calling form in Acrobat 7 while it will be just fine using Acrobat 9...
Would you know anything about that? -
How to get a second page in a form letter report after create it by Wizard
How to get a second page in a form letter report after create it by Wizard
i've built a report by wizard with a sql-Query
the sql give me back for example 3 dataset
and the report prints 3 pages
dataset 1 - page 1
dataset 2 - page 1
dataset 3 - page 1
thats ok,
but now I need a second page per dataset ( with only a text )
so that the report should print 2 pages per dataset
dataset 1 - page 1 ,page 2
dataset 2 - page 1 ,page 2
dataset 3 - page 1 ,page 2
It's not really clear for me, what to do, to create the second page
any help ?.... found answer in other forum
-
Trying a recovery from a livedisc and chroot fails to run /bin/bash?!?
The title pretty much says it all.
Trying to do a repair on my daughter's laptop, booting from a live image on USB. It's an old eeepc with only 1 partition, all on sda1.
I'm using the Kernel Panics wiki like I usually do when I have to go through this: ( https://wiki.archlinux.org/index.php/Kernel_panic) but when I try to chroot, I get this:
chroot: failed to run comman '/bin/bash': No such file or directory
Any ideas? I'm pulling my hair out here.Ah, maybe you're trying to use a 64-bit binaries from the USB on a 32-bit system or vice-versa.
Last edited by karol (2010-12-15 18:28:42) -
Need to ommit the short form letter from the given string
HI,
I need to ommit the Short form letter from column data.
EX :
CREATE table #testdata
(id int identity(1,1),cust_address varchar(max))
insert into #testdata (cust_address)
select 'first street 5N, North'
union
select 'second street W, west'
union
select 'roja street 5S, South'
union
select 'temple street E, East'
union
select 'first street, Northwest, NW'
union
select 'first street, Southwest, SW'
select * from #testdata
actutal out put:
id cust_address
1 first street 5N, North
2 first street, Northwest, NW
3 first street, Southwest, SW
4 roja street 5S, South
5 second street W, west
6 temple street E, East
Need to ommit the Short form letter from this output,
condition , 1) the short form letter should have space in front of the letter ex : first street (space)N, North
so the output should be "first street, North" like that for other words like "first street, Southwest, SW" should be "first street, Southwest"
2) the short form letter should not combine with any other letter ex : first street 5N, North
here we dont need to do anything.
Required Out put :
id cust_address
1 first street 5N, North
2 first street, Northwest
3 first street, Southwest
4 roja street 5S, South
5 second street, west
6 temple street, East
Nandha KumarCREATE FUNCTION [dbo].[SplitString]
@str VARCHAR(MAX)
RETURNS @ret TABLE (token VARCHAR(MAX))
AS
BEGIN
DECLARE @x XML
SET @x = '<t>' + REPLACE(@str, ',', '</t><t>') + '</t>'
INSERT INTO @ret
SELECT x.i.value('.', 'VARCHAR(MAX)') AS token
FROM @x.nodes('//t') x(i)
RETURN
END
with cte
as
select *
from #testdata
CROSS APPLY (SELECT * FROM [dbo].[SplitString](cust_address)) AS der
) ,cte1
as
select *,
case when UPPER(token)=token COLLATE Latin1_General_BIN
then '' else token end as d
from cte
) ,CTE2
AS
(SELECT *,case when RIGHT(UPPER(D),1)=RIGHT(D,1) COLLATE Latin1_General_BIN
then replace(D,RIGHT(UPPER(D),1),'') else token end d1 FROM CTE1
SELECT m1.id,
( SELECT m2.D1 + ','
FROM cte2 m2
WHERE m2.id = m1.id
ORDER BY id
FOR XML PATH('') ) AS token
FROM cte2 m1
GROUP BY m1.id
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
FM or classes for word form letter ?
hi there,
can anybody tell me how i can use the 'form letter' function out of an abap ?
some classes or fm's ?
i want to open WORD for windows with specific fields for form letter processing.
best regards, MartinHi,
check this sample prog in se38.........
SAPRDEMODOCUMENTCONTAINER
Cheers,
jose. -
Is it possible to mailmerge a form letter so that the mailmerge process produces separate pdf files, one for each recipient identified in a database (names, addresses, etc.)?
Or is is it possible to mailmerge a form letter so that the mailmerge process produces one big file that contains a copy of the form letter for each recipient identified in a database?Hi marceepoo,
If you're using Word for Windows, you sure can. See Adobe Acrobat X Pro * Create PDFs from Word mail merges
Best,
Sara -
Authentication error with shell=/usr/bin/bash
Hello there,
I'm comfortable with linux, but new with Arch Linux. Recently I completed an installation with success but I ran into a strange authentication error at login.
Before adding a user I verified the path of the bash shell and 'which bash' returned /usr/bin/bash.
So I added a user with shell /usr/bin/bash and the line in /etc/passwd reads similar to:
newuser:x:1000:100:His name:/home/newuser:/usr/bin/bash
With this line I get an authentication error from login
And when I change the shell to /bin/bash, the user is able to login with success.
I have found similar problem reports, but not this solution.
I hope to get some help with understanding this issue, to me it seems wrong to point the shell in /etc/passwd to a symbolic link.Thank you very much, falconindy.
My first reaction is "But what if /usr becomes inaccessible", also /bin/sh is a symlink.
But I guess with rescue options from initramfs or live CD/usb, this is not a big issue anymore.
I have added /usr/bin/bash to /etc/shells.
Last edited by wilbert-vb (2013-05-18 12:55:45)
Maybe you are looking for
-
my mac book pro stolen, can u please block or track it,do u need serial nomber? <Personal Information Edited By Host>
-
Cheque incorrectly stopped in FI, even though it was cashed.
Dear Gurus Please can you help to see how we can do this - I am not sure of this scenario - It basically looks like a cheque was incorrectly stopped/cancelled the by us, even though the person actually cashed this cheque back in 2009. This was due to
-
Still photo in FCP exported to Photoshop, not matching aspect ratio
Hi, I made a still photo in FCP. Sent to Photoshop. Imported back in FCP. Image is squished. I am using DV NTSC 720x480. In Photoshop I also set Image Size to 720x480. For some reason I cant get it to match in FCP. Any idea how I an fix this? Thanks.
-
Mail not showing in inbox.
Hi, I am trying to send a mail to SBWP. what is happening is i am able to see the mail in outbox but not in inbox. let me know what do i do?
-
Search help for usrid, first name , last name
Hi Experts, Requirement: An input field with search help where user can search an employee based on his last name, first name (PA0002 u2013 NACHN and VORNA ) or user id(PA0105-USRID). (Wild card entries should be allowed) It should always return the